Q3ValueListIterator Class ReferenceThe 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. Public Functions
Detailed DescriptionThe 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
|
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 4.8 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com