Home · All Namespaces · All Classes · Main Classes · Grouped Classes · Modules · Functions |
The Q3ValueListIterator class provides an iterator for Q3ValueList. More...
#include <Q3ValueListIterator>
This class is part of the Qt 3 support library. It is provided to keep old source code working. We strongly advise against using it in new code. See Porting to Qt 4 for more information.
Inherits QLinkedList<T>::iterator.
The Q3ValueListIterator class provides an iterator for Q3ValueList.
An iterator is a class for accessing the items of a container class: a generalization of the index in an array. A pointer into a "const char *" and an index into an "int[]" are both iterators, and the general idea is to provide that functionality for any data structure.
The Q3ValueListIterator class is an iterator for Q3ValueList instantiations. You can create the appropriate iterator type by using the iterator typedef provided by Q3ValueList.
The only way to access the items in a Q3ValueList is to use an iterator.
Example (see Q3ValueList for the complete code):
EmployeeList::iterator it; for ( it = list.begin(); it != list.end(); ++it ) cout << (*it).surname().latin1() << ", " << (*it).forename().latin1() << " earns " << (*it).salary() << endl; // Output: // Doe, John earns 50000 // Williams, Jane earns 80000 // Hawthorne, Mary earns 90000 // Jones, Tom earns 60000
Q3ValueList is highly optimized for performance and memory usage. This means that you must be careful: Q3ValueList does not know about all its iterators and the iterators don't know to which list they belong. This makes things very fast, but if you're not careful, you can get spectacular bugs. Always make sure iterators are valid before dereferencing them or using them as parameters to generic algorithms in the STL.
Using an invalid iterator is undefined (your application will probably crash). Many Qt functions return const value lists; to iterate over these you should make a copy and iterate over the copy.
For every Iterator there is a ConstIterator. When accessing a Q3ValueList in a const environment or if the reference or pointer to the list is itself const, then you must use the ConstIterator. Its semantics are the same as the Iterator, but it only returns const references.
See also Q3ValueList and Q3ValueListConstIterator.
Constructs an unitialized iterator.
Constucts a copy of iterator o.
Constucts a copy of iterator o.
Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies) | Trademarks | Qt 4.5.1 |