JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

हिंदी माध्यम नोट्स

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi sociology physics physical education maths english economics geography History

chemistry business studies biology accountancy political science

Class 12

Hindi physics physical education maths english economics

chemistry business studies biology accountancy Political science History sociology

Home science Geography

English medium Notes

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Class 12

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Categories: c++ language in hindi

Iterator Type in c++ language , Input Iterator , Output , Forward , Bidirectional , Random Access Iterator

इससे पहले के article मे , Iterator को discuss किया था अब इस article मे , Iterator के type को discuss करेगे |
Iterator Categories
किसी Iterator के type निन्म है : –
Input Iterator
Output Iterator
Forward Iterator
Bidirectional Iterator
Random Access Iterator
Input Iterator:
इस input Iterator एक Iterator है जिसका use किसी container के element को access करने के लिए किया जाता है |लेकिन इनकी value को modify नहीं किया जा सकता है |
input Iterator पर निन्म operation को फॉलो किया जाता है :-
Operator (++) : इस operation मे , iterator को एक से increament किया जाता है | अतः iterator किसी data type के next data को point करता है |
Operator (==) and Operator (!=) : इस operator का use ये check करने के लिए किया जाता है की दो iterator एक ही position को point करते है या नहीं |
Operator (=) : इस operation का use किसी iterator मे value को assign करने के लिए किया जाता है |
Output Iterator:
output Iterator का use किसी container की value को modify करने के लिए किया जाता है | लेकिने in value को कभी कभी भी access या read नहीं कियता जा सकता है | इसलिए Output Iterator का use केवल write-only iterator होता है |
Output Iterator पर निन्म operation को फॉलो किया जाता है :-
Operator (++) : इस operation मे , iterator को एक से increament किया जाता है | अतः iterator किसी data type के next data को point करता है |
Operator (=) : इस operation का use किसी iterator मे value को assign करने के लिए किया जाता है |
Forward Iterator:
इस Iterator का use किसी container की value को read और write करने के लिय किया जाता है | इससे multi pass Iterator कहते है |
Forward Iterator पर निन्म operation को फॉलो किया जाता है :-
Operator (++) : इस operation मे , iterator को एक से increament किया जाता है | अतः iterator किसी data type के next data को point करता है |
Operator (==) and Operator (!=) : इस operator का use ये check करने के लिए किया जाता है की दो iterator एक ही position को point करते है या नहीं |
Operator (=) : इस operation का use किसी iterator मे value को assign करने के लिए किया जाता है |
Bidirectional iterator:
इस iterator मे Forward Iterator की सभीcapability को add किया गया है  इसके अलावा इस  Iterator मे एक और capability decrement को add किया गया है  decrement operator(–): इसका use किसी container मे value को backward डायरेक्शन मे access करने के लिए किया जाता है |
Bidirectional Iterator पर निन्म operation को फॉलो किया जाता है :-
Operator (++) : इस operation मे , iterator को एक से increament किया जाता है | अतः iterator किसी data type के next data को point करता है |
Operator (==) and Operator (!=) : इस operator का use ये check करने के लिए किया जाता है की दो iterator एक ही position को point करते है या नहीं |
Operator (=) : इस operation का use किसी iterator मे value को assign करने के लिए किया जाता है |
Decrement operator(–) : इस operation मे , iterator को एक से decreament किया जाता है | अतः iterator किसी data type के पिछला data को point करता है |
Random Access Iterator:
A Random Access iterator एक iterator है जिसका use किसी container के value को random access करने केलिए किया जाता है |इसमें Bidirectional iterator के सभी गुण को add किया गया है इसके अलावा इसमें pointer addition and pointer subtraction को add किया जग्य है जिसका use किसी container के data को random access के लिए use किया जाता है |
#include <iostream>
#include<vector>
#include<iterator>
using namespace std;
int main()
{
vector<int> v{1,2,3,4,5};
vector<int>::iterator i;
for(int i=0;i<5;i++)           // Traversal without using an iterator.
{
cout<<v[i]<<” “;
}
cout<<‘\n’;
for(i=v.begin();i!=v.end();i++)  // Traversal by using an iterator.
{
cout<<*i<<” “;
}
v.push_back(10);
cout<<‘\n’;
for(int i=0;i<6;i++)
{
cout<<v[i]<<” “;
}
cout<<‘\n’;
for(i=v.begin();i!=v.end();i++)
{
cout<<*i<<” “;
}
return 0;
}
जब इस code को execute किया जाता है तब इसका आउटपुट निन्म होगा :-
Output:
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5 10
1 2 3 4 5 10
इस code मे , vector के सभी element को जब iterator के बिना  traverse किया जाता है तब हमे ये ट्रैक करना पड़ता है की container मे कितनी value को add किया गया है | लेकिन iterator के साथ एस नहीं करना होता है |
Code Reusability:
जब हम किसी iterator को use करते है तब code को reuse किया जा सकता है |  upper वाले code मे vector को लिस्ट से replace कर देते है | तब operator [] से किसी लिस्ट के element को random access नहीं किया जा सकता है | लेकिन जब हम iterator को use करते है तब इस लिस्ट के element को access किया जा सकता है |
Dynamic Processing:
c++ iterator का use किसी लिस्ट मे data value को add और डिलीट करने की facility भी होती है इससे Dynamic Processing कहते है |
code :
#include <iostream>
#include<vector>
#include<iterator>
using namespace std;
void  main()
{
vector<int> b{1,2,3,4,5};  // vector declaration
vector<int>::iterator j;
b.insert(b.begin()+1,10);
for(j=b.begin();j=b.end();j++)
{
cout<<*j<<” “;
}
getch();
}
Output:
1 10 2 3 4 5
इस article मे iterator के type को discuss किया है अब आगे के article मे c++ language के advance concept को discuss किया गया है |
Sbistudy

Recent Posts

four potential in hindi 4-potential electrodynamics चतुर्विम विभव किसे कहते हैं

चतुर्विम विभव (Four-Potential) हम जानते हैं कि एक निर्देश तंत्र में विद्युत क्षेत्र इसके सापेक्ष…

3 days ago

Relativistic Electrodynamics in hindi आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा

आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा Relativistic Electrodynamics in hindi ? अध्याय : आपेक्षिकीय विद्युतगतिकी…

4 days ago

pair production in hindi formula definition युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए

युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए pair production in hindi formula…

7 days ago

THRESHOLD REACTION ENERGY in hindi देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा

देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा THRESHOLD REACTION ENERGY in hindi…

7 days ago

elastic collision of two particles in hindi definition formula दो कणों की अप्रत्यास्थ टक्कर क्या है

दो कणों की अप्रत्यास्थ टक्कर क्या है elastic collision of two particles in hindi definition…

7 days ago
All Rights ReservedView Non-AMP Version
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings
JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now