1QPtrListIterator(3qt)                                    QPtrListIterator(3qt)
2
3
4

NAME

6       QPtrListIterator - Iterator for QPtrList collections
7

SYNOPSIS

9       #include <qptrlist.h>
10
11       Inherited by QObjectListIterator and QStrListIterator.
12
13   Public Members
14       QPtrListIterator ( const QPtrList<type> & list )
15       ~QPtrListIterator ()
16       uint count () const
17       bool isEmpty () const
18       bool atFirst () const
19       bool atLast () const
20       type * toFirst ()
21       type * toLast ()
22       operator type * () const
23       type * operator* ()
24       type * current () const
25       type * operator() ()
26       type * operator++ ()
27       type * operator+= ( uint jump )
28       type * operator-- ()
29       type * operator-= ( uint jump )
30       QPtrListIterator<type> & operator= ( const QPtrListIterator<type> & it
31           )
32

DESCRIPTION

34       The QPtrListIterator class provides an iterator for QPtrList
35       collections.
36
37       Define a template instance QPtrListIterator<X> to create a list
38       iterator that operates on QPtrList<X> (list of X*).
39
40       The following example is similar to the example in the QPtrList class
41       documentation, but it uses QPtrListIterator. The class Employee is
42       defined there.
43
44           QPtrList<Employee> list;
45           list.append( new Employee("John", "Doe", 50000) );
46           list.append( new Employee("Jane", "Williams", 80000) );
47           list.append( new Employee("Tom", "Jones", 60000) );
48           QPtrListIterator<Employee> it( list );
49           Employee *employee;
50           while ( (employee = it.current()) != 0 ) {
51               ++it;
52               cout << employee->surname().latin1() << ", " <<
53                       employee->forename().latin1() << " earns " <<
54                       employee->salary() << endl;
55           }
56
57       The output is
58
59           Doe, John earns 50000
60           Williams, Jane earns 80000
61           Jones, Tom earns 60000
62
63       Using a list iterator is a more robust way of traversing the list than
64       using the QPtrList member functions first(), next(), current(), etc.,
65       as many iterators can traverse the same list independently.
66
67       An iterator has its own current list item and can get the next and
68       previous list items. It doesn't modify the list in any way.
69
70       When an item is removed from the list, all iterators that point to that
71       item are updated to point to QPtrList::current() instead to avoid
72       dangling references.
73
74       See also QPtrList, Collection Classes, and Non-GUI Classes.
75

MEMBER FUNCTION DOCUMENTATION

QPtrListIterator::QPtrListIterator ( const QPtrList<type> & list )

78       Constructs an iterator for list. The current iterator item is set to
79       point on the first item in the list.
80

QPtrListIterator::~QPtrListIterator ()

82       Destroys the iterator.
83

bool QPtrListIterator::atFirst () const

85       Returns TRUE if the current iterator item is the first list item;
86       otherwise returns FALSE.
87
88       See also toFirst() and atLast().
89

bool QPtrListIterator::atLast () const

91       Returns TRUE if the current iterator item is the last list item;
92       otherwise returns FALSE.
93
94       See also toLast() and atFirst().
95

uint QPtrListIterator::count () const

97       Returns the number of items in the list this iterator operates on.
98
99       See also isEmpty().
100
101       Example: customlayout/card.cpp.
102

type * QPtrListIterator::current () const

104       Returns a pointer to the current iterator item. If the iterator is
105       positioned before the first item in the list or after the last item in
106       the list, 0 is returned.
107
108       Examples:
109

bool QPtrListIterator::isEmpty () const

111       Returns TRUE if the list is empty; otherwise returns FALSE.
112
113       See also count().
114

QPtrListIterator::operator type * () const

116       Cast operator. Returns a pointer to the current iterator item. Same as
117       current().
118

type * QPtrListIterator::operator() ()

120       Makes the succeeding item current and returns the original current
121       item.
122
123       If the current iterator item was the last item in the list or if it was
124       0, 0 is returned.
125

type * QPtrListIterator::operator* ()

127       Asterisk operator. Returns a pointer to the current iterator item. Same
128       as current().
129

type * QPtrListIterator::operator++ ()

131       Prefix ++ makes the succeeding item current and returns the new current
132       item.
133
134       If the current iterator item was the last item in the list or if it was
135       0, 0 is returned.
136

type * QPtrListIterator::operator+= ( uint jump )

138       Sets the current item to the item jump positions after the current item
139       and returns a pointer to that item.
140
141       If that item is beyond the last item or if the list is empty, it sets
142       the current item to 0 and returns 0
143

type * QPtrListIterator::operator-- ()

145       Prefix - makes the preceding item current and returns the new current
146       item.
147
148       If the current iterator item was the first item in the list or if it
149       was 0, 0 is returned.
150

type * QPtrListIterator::operator-= ( uint jump )

152       Returns the item jump positions before the current item or 0 if it is
153       beyond the first item. Makes this the current item.
154

QPtrListIterator<type> & QPtrListIterator::operator= ( const

156       QPtrListIterator<type> & it )
157       Assignment. Makes a copy of the iterator it and returns a reference to
158       this iterator.
159

type * QPtrListIterator::toFirst ()

161       Sets the current iterator item to point to the first list item and
162       returns a pointer to the item. Sets the current item to 0 and returns 0
163       if the list is empty.
164
165       See also toLast() and atFirst().
166

type * QPtrListIterator::toLast ()

168       Sets the current iterator item to point to the last list item and
169       returns a pointer to the item. Sets the current item to 0 and returns 0
170       if the list is empty.
171
172       See also toFirst() and atLast().
173
174

SEE ALSO

176       http://doc.trolltech.com/qptrlistiterator.html
177       http://www.trolltech.com/faq/tech.html
178
180       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
181       license file included in the distribution for a complete license
182       statement.
183

AUTHOR

185       Generated automatically from the source code.
186

BUGS

188       If you find a bug in Qt, please report it as described in
189       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
190       help you. Thank you.
191
192       The definitive Qt documentation is provided in HTML format; it is
193       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
194       web browser. This man page is provided as a convenience for those users
195       who prefer man pages, although this format is not officially supported
196       by Trolltech.
197
198       If you find errors in this manual page, please report them to qt-
199       bugs@trolltech.com.  Please include the name of the manual page
200       (qptrlistiterator.3qt) and the Qt version (3.3.8).
201
202
203
204Trolltech AS                    2 February 2007          QPtrListIterator(3qt)
Impressum