Re: Iterators act like numbers? Programming Software Development by ArkM Iterators are not numbers. Iterators are abstract pointers (remember pointer arithmetics in C)! Re: Iterators Programming Software Development by mike_2000_17 You have to think of iterators like pointers. The idea of iterators is to mimic this C-like for-loop: [CODE]…pointer to access the value. [/CODE] The use of iterators is very similar, except that the start and end iterator… the iterator) is the same as for pointers (although iterators may not support all operations), and you need to dereference… Re: iterators Programming Software Development by dusktreader …QUOTE=tennis;1320858]say iter1 and iter2 are both iterators [CODE]*iter1++=*iter2++;[/CODE] what does this line…[/I]. 6. After the line finishes execution, both iterators will be incremented to refer to their next values.…do this at least until you are more comfortable with iterators and how they work: [icode]*(iter1++)=*(iter2++);[/icode]… Iterators? Programming Software Development by pseudorandom21 How are iterators used in C# ? suppose I have say: [code] List<… are added here */ /* and now I wonder if C++ style iterators are available? */ for( var i = /* iterator begin of list */ ; i… Re: Iterators? Programming Software Development by kvprajapati [b]How are iterators used in C# ?[/b] Text from MSDN [URL="http://… iterators Programming Software Development by tennis say iter1 and iter2 are both iterators [CODE]*iter1++=*iter2++;[/CODE] what does this line means? Can anybody help explain? ++ and * which is done first? thanks Iterators Programming Software Development by powerdink …; } [/code] This worsks fine, but I'm trying to understand iterators and how they can be used, so I've created… Re: Iterators and Vectors Programming Software Development by wisaacs … from another one. It is iterators you can subtract, because iterators work like pointers. And, like pointers, iterators do not touch the data… = x.end(); // this is another iterator int LEN = end-begin; // iterators within the same container can be subtracted // try subtracting two… Re: Iterators act like numbers? Programming Software Development by GDICommander …, if I understand, you are relying on memory addresses of iterators to do a substraction and get the index? If the… memory for the iterators is allocated at a totally bizarre place, the substraction will… that the common methods on the std::vector class takes iterators, so you don't even need the index. Using … Re: Iterators and Vectors Programming Software Development by wisaacs …address is the count of that particular storage place. And, iterators are like pointers, that is, addresses in computer memory.… you might have guessed, you can do the same with iterators. [code=cpp] vector<int> vArr; // an….end(),i*5); // fill it // step through, using iterators for( vector<int>::iterator iter= vArr.begin(); iter… Re: Iterators and Vectors Programming Software Development by wisaacs …vector<string> are like arrays of strings. Iterators to a string collection also work the same. Pointers to… end= v.end(); // one past the last element // iterators can be subtracted printf( "the number of strings in… v is: %d\n", // difference between two iterators, in a vector of strings end-begin ); } [/code] Re: Iterators and Vectors Programming Software Development by crapgarden … from another one. It is iterators you can subtract, because iterators work like pointers. And, like pointers, iterators do not touch the data… Iterators and const iterators Programming Software Development by Shaabangbang … done, but I'm a little stumped with the const iterators.. can you please point me in the right direction? This… is my data structure for the iterators: [CODE] template <typename T> class Iter : public std… Iterators act like numbers? Programming Software Development by daviddoria …() from the iterator that find() returns. Has - been overloaded for iterators to do some magic and return the offset? Or are… iterators simply these offsets? [code] unsigned int num = 10; vector<… Re: Iterators act like numbers? Programming Software Development by StuXYZ … std::distance function to determine the distance between two sequentual iterators. e.g. [code=c++] std::vector<int> A… iterator is not random access so you can use +/- between iterators. But distance is ok. Iterators and Vectors Programming Software Development by crapgarden … 2nd Edition". The chapter goes over STL, vectors and iterators. The assignment is to create a program that allows the… than once per cycle in these cases? 2 - Deferencing Iterator Iterators established earlier: vector<string>::iterator myIterator; vector<… Re: Iterators and Vectors Programming Software Development by mrnutty For #2, iterators are just classes. They have certain operation defined for them. … library does not define the operator << for the iterators, thus it is a compiler error. For #3, "selection… Re: Iterators and Vectors Programming Software Development by crapgarden …;< endl;[/CODE] Above, first person explained:[QUOTE]For #2, iterators are just classes. They have certain operation defined for them… library does not define the operator << for the iterators, thus it is a compiler error. [/QUOTE] Any idea how… Re: Iterators and Vectors Programming Software Development by wisaacs firstPerson is right. Iterators are designed to work like array pointers. So, in C, … Re: Iterators and Vectors Programming Software Development by crapgarden ha, yeah that's pretty stupid. How can you subtract "Cow" from "Toyota Hybrid"? I get it now, the iterators can work mathematically because the containers they refer to can be used as mathematical values....right? Closer? Re: Iterators and Vectors Programming Software Development by mrnutty …; from "Toyota Hybrid"? I get it now, the iterators can work mathematically because the containers they refer to can… Iterators and Deques Programming Software Development by cesarmas I tried to make a function , using iterators, to walk a deque backward and my function does not … Re: iterators Programming Software Development by Duki Using the ++ operator on a pointer is different from a traditional variable. *ptr++ will increment the memory space which ptr is pointing to based on the variable type. For example, if you have [code=c++]int *ptr;[/code]and suppose it's pointing at memory location 1000. We know that an integer is 4 bytes, right? So if we do [code=c++]*ptr… Re: iterators Programming Software Development by Fbody [QUOTE="Duki"]Someone should probably check my answer on this part though...[/QUOTE] I think you have your funcionality backward. Using this code: [CODE]#include <cstdlib> #include <ctime> #include <iostream> #include <vector> using namespace std; typedef vector<int>::const_iterator constIntIter;… Re: iterators Programming Software Development by Duki Thank you. Re: Iterators Programming Software Development by powerdink Thanks Mikael, That makes so much more sense now. I didn't even think of removing size, since with the iterator I wouldn't need it. The point of using a const help also. I have another function that I probably should be using that on as well. Thanks again. Re: Iterators Programming Software Development by mike_2000_17 Yeah, you should not pass large objects by value, so a const-reference is preferred to avoid the expensive copying. Re: Iterators for data abstraction? Programming Software Development by mrnutty … think its violating encapsulation? And btw, queue does not have iterators. Re: Iterators on Sets Programming Software Development by Skyelher … for me. But I wanted to learn how to use iterators and I couldn't find the fault. When I use… debug assertion failed when using vector iterators Programming Software Development by spetsnaz26 … pointers to vectors and ran into some problem with iterators. I'm using Visual Studio 2005 SP1. In …of the same kind. I read the part about iterators and containers in C++ Primer back and forth … what's wrong with my use of iterators. The book says iterators can be invalidated if the size of…this be related to my possible misuse of iterators?