Qt:Документация 4.3.2/q3valuelistiterator

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

[править] Q3ValueListIterator Class Reference
[ Qt3Support module]

The Q3ValueListIterator class provides an iterator for Q3ValueList. Далее...

 #include <Q3ValueListIterator>

This class is part of the Qt 3 support library. It is provided to keep old source code working. Мы настоятельно не рекомендуем использовать этот класс в новом коде. 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.


[править] Описание функций-членов

[править]
Q3ValueListIterator::Q3ValueListIterator ()

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.



Copyright © 2007 Trolltech Trademarks
Qt 4.3.2