Q3ValueListIterator Class

The Q3ValueListIterator class provides an iterator for Q3ValueList. More...

Header: #include <Q3ValueListIterator>
Inherits: QLinkedList<T>::iterator

Public Functions

Q3ValueListIterator(const Q3ValueListIterator & o)
Q3ValueListIterator(const QLinkedList<T>::iterator & o)

Detailed Description

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.

Member Function Documentation


Constructs an unitialized iterator.

Q3ValueListIterator::Q3ValueListIterator(const Q3ValueListIterator & o)

Constucts a copy of iterator o.

Q3ValueListIterator::Q3ValueListIterator(const QLinkedList<T>::iterator & o)

Constucts a copy of iterator o.

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.