![]() |
| ||
Classes - Annotated - Tree - Functions - Home - Structure |
The QPtrDictIterator class provides an iterator for QPtrDict collections. More...
#include <qptrdict.h>
QPtrDictIterator is implemented as a template class. Define a template instance QPtrDictIterator<X> to create a dictionary iterator that operates on QPtrDict<X> (dictionary of X*).
Example:
#include <qptrdict.h> #include <stdio.h> int main() { int *a = new int[12]; int *b = new int[10]; int *c = new int[18]; int *d = new int[13]; QPtrDict<char> dict; // maps void* -> char* dict.insert( a, "a is int[12]" ); // describe pointers dict.insert( b, "b is int[10]" ); dict.insert( c, "c is int[18]" ); QPtrDictIterator<char> it( dict ); // iterator for dict while ( it.current() ) { printf( "%x -> %s\n", it.currentKey(), it.current() ); ++it; } return 0; }
Program output:
804a788 -> a is int[12] 804a7f0 -> c is int[18] 804a7c0 -> b is int[10]
Note that the traversal order is arbitrary; you are not guaranteed the order above.
Multiple iterators may independently traverse the same dictionary. A QPtrDict knows about all iterators that are operating on the dictionary. When an item is removed from the dictionary, QPtrDict updates all iterators that refer the removed item to point to the next item in the traversing order.
See also QPtrDict and Collection Classes.
See also isEmpty().
See also count().
If the current iterator item was the last item in the dictionary or if it was null, null is returned.
If the current iterator item was the last item in the dictionary or if it was null, null is returned.
If that item is beyond the last item or if the dictionary is empty, it sets the current item to null and returns null.
Search the documentation, FAQ, qt-interest archive and more (uses
www.trolltech.com):
This file is part of the Qt toolkit, copyright © 1995-2001 Trolltech, all rights reserved.
Copyright © 2001 Trolltech | Trademarks | Qt version 3.0.0-beta2
|