| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the documentation of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:FDL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in a
|
|---|
| 14 | ** written agreement between you and Nokia.
|
|---|
| 15 | **
|
|---|
| 16 | ** GNU Free Documentation License
|
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Free
|
|---|
| 18 | ** Documentation License version 1.3 as published by the Free Software
|
|---|
| 19 | ** Foundation and appearing in the file included in the packaging of this
|
|---|
| 20 | ** file.
|
|---|
| 21 | **
|
|---|
| 22 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 23 | ** Nokia at [email protected].
|
|---|
| 24 | ** $QT_END_LICENSE$
|
|---|
| 25 | **
|
|---|
| 26 | ****************************************************************************/
|
|---|
| 27 |
|
|---|
| 28 | /*!
|
|---|
| 29 | \class Q3ValueList
|
|---|
| 30 | \brief The Q3ValueList class is a value-based template class that
|
|---|
| 31 | provides lists.
|
|---|
| 32 | \compat
|
|---|
| 33 |
|
|---|
| 34 | Q3ValueList is a Qt implementation of an STL-like list container.
|
|---|
| 35 | It can be used in your application if the standard \c list is not
|
|---|
| 36 | available for your target platforms.
|
|---|
| 37 |
|
|---|
| 38 | Q3ValueList\<T\> defines a template instance to create a list of
|
|---|
| 39 | values that all have the class T. Note that Q3ValueList does not
|
|---|
| 40 | store pointers to the members of the list; it holds a copy of
|
|---|
| 41 | every member. This is why these kinds of classes are called "value
|
|---|
| 42 | based"; Q3PtrList and Q3Dict are "pointer based".
|
|---|
| 43 |
|
|---|
| 44 | Q3ValueList contains and manages a collection of objects of type T
|
|---|
| 45 | and provides iterators that allow the contained objects to be
|
|---|
| 46 | addressed. Q3ValueList owns the contained items. For more relaxed
|
|---|
| 47 | ownership semantics, see Q3PtrCollection and friends which are
|
|---|
| 48 | pointer-based containers.
|
|---|
| 49 |
|
|---|
| 50 | Some classes cannot be used within a Q3ValueList, for example, all
|
|---|
| 51 | classes derived from QObject and thus all classes that implement
|
|---|
| 52 | widgets. Only values can be used in a Q3ValueList. To qualify as a
|
|---|
| 53 | value the class must provide:
|
|---|
| 54 | \list
|
|---|
| 55 | \i a copy constructor;
|
|---|
| 56 | \i an assignment operator;
|
|---|
| 57 | \i a default constructor, i.e. a constructor that does not take any arguments.
|
|---|
| 58 | \endlist
|
|---|
| 59 |
|
|---|
| 60 | Note that C++ defaults to field-by-field assignment operators and
|
|---|
| 61 | copy constructors if no explicit version is supplied. In many
|
|---|
| 62 | cases this is sufficient.
|
|---|
| 63 |
|
|---|
| 64 | In addition, some compilers (e.g. Sun CC) might require that the
|
|---|
| 65 | class provides an equality operator (operator==()).
|
|---|
| 66 |
|
|---|
| 67 | Q3ValueList's function naming is consistent with the other Qt
|
|---|
| 68 | classes (e.g. count(), isEmpty()). Q3ValueList also provides extra
|
|---|
| 69 | functions for compatibility with STL algorithms, such as size()
|
|---|
| 70 | and empty(). Programmers already familiar with the STL \c list may
|
|---|
| 71 | prefer to use the STL-compatible functions.
|
|---|
| 72 |
|
|---|
| 73 | Example:
|
|---|
| 74 | \snippet doc/src/snippets/code/doc_src_q3valuelist.qdoc 0
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 | Notice that the latest changes to Mary's salary did not affect the
|
|---|
| 78 | value in the list because the list created a copy of Mary's entry.
|
|---|
| 79 |
|
|---|
| 80 | There are several ways to find items in the list. The begin() and
|
|---|
| 81 | end() functions return iterators to the beginning and end of the
|
|---|
| 82 | list. The advantage of getting an iterator is that you can move
|
|---|
| 83 | forward or backward from this position by
|
|---|
| 84 | incrementing/decrementing the iterator. The iterator returned by
|
|---|
| 85 | end() points to the item which is one \e past the last item in the
|
|---|
| 86 | container. The past-the-end iterator is still associated with the
|
|---|
| 87 | list it belongs to, however it is \e not dereferenceable;
|
|---|
| 88 | operator*() will not return a well-defined value. If the list is
|
|---|
| 89 | empty(), the iterator returned by begin() will equal the iterator
|
|---|
| 90 | returned by end().
|
|---|
| 91 |
|
|---|
| 92 | It is safe to have multiple iterators a the list at the same
|
|---|
| 93 | time. If some member of the list is removed, only iterators
|
|---|
| 94 | pointing to the removed member become invalid. Inserting into the
|
|---|
| 95 | list does not invalidate any iterator. For convenience, the
|
|---|
| 96 | function last() returns a reference to the last item in the list,
|
|---|
| 97 | and first() returns a reference to the first item. If the
|
|---|
| 98 | list is empty(), both last() and first() have undefined behavior
|
|---|
| 99 | (your application will crash or do unpredictable things). Use
|
|---|
| 100 | last() and first() with caution, for example:
|
|---|
| 101 |
|
|---|
| 102 | \snippet doc/src/snippets/code/doc_src_q3valuelist.qdoc 1
|
|---|
| 103 |
|
|---|
| 104 | Because Q3ValueList is value-based there is no need to be careful
|
|---|
| 105 | about deleting items in the list. The list holds its own copies
|
|---|
| 106 | and will free them if the corresponding member or the list itself
|
|---|
| 107 | is deleted. You can force the list to free all of its items with
|
|---|
| 108 | clear().
|
|---|
| 109 |
|
|---|
| 110 | Q3ValueList is shared implicitly, which means it can be copied in
|
|---|
| 111 | constant time, i.e. O(1). If multiple Q3ValueList instances share
|
|---|
| 112 | the same data and one needs to modify its contents, this modifying
|
|---|
| 113 | instance makes a copy and modifies its private copy; therefore it
|
|---|
| 114 | does not affect the other instances; this takes O(n) time. This is
|
|---|
| 115 | often called "copy on write". If a Q3ValueList is being used in a
|
|---|
| 116 | multi-threaded program, you must protect all access to the list.
|
|---|
| 117 | See \l QMutex.
|
|---|
| 118 |
|
|---|
| 119 | There are several ways to insert items into the list. The
|
|---|
| 120 | prepend() and append() functions insert items at the beginning and
|
|---|
| 121 | the end of the list respectively. The insert() function comes in
|
|---|
| 122 | several flavors and can be used to add one or more items at
|
|---|
| 123 | specific positions within the list.
|
|---|
| 124 |
|
|---|
| 125 | Items can also be removed from the list in several ways. There
|
|---|
| 126 | are several variants of the remove() function, which removes a
|
|---|
| 127 | specific item from the list. The remove() function will find and
|
|---|
| 128 | remove items according to a specific item value.
|
|---|
| 129 |
|
|---|
| 130 | \sa Q3ValueListIterator
|
|---|
| 131 | */
|
|---|
| 132 |
|
|---|
| 133 | /*! \typedef Q3ValueList::iterator
|
|---|
| 134 | The list's iterator type, Q3ValueListIterator. */
|
|---|
| 135 | /*! \typedef Q3ValueList::const_iterator
|
|---|
| 136 | The list's const iterator type, Q3ValueListConstIterator. */
|
|---|
| 137 | /*! \typedef Q3ValueList::value_type
|
|---|
| 138 | The type of the object stored in the list, T. */
|
|---|
| 139 | /*! \typedef Q3ValueList::pointer
|
|---|
| 140 | The pointer to T type. */
|
|---|
| 141 | /*! \typedef Q3ValueList::const_pointer
|
|---|
| 142 | The const pointer to T type. */
|
|---|
| 143 | /*! \typedef Q3ValueList::reference
|
|---|
| 144 | The reference to T type. */
|
|---|
| 145 | /*! \typedef Q3ValueList::const_reference
|
|---|
| 146 | The const reference to T type. */
|
|---|
| 147 | /*! \typedef Q3ValueList::size_type
|
|---|
| 148 | An unsigned integral type, used to represent various sizes. */
|
|---|
| 149 | /*! \typedef Q3ValueList::difference_type
|
|---|
| 150 | \internal
|
|---|
| 151 | */
|
|---|
| 152 | /*!
|
|---|
| 153 | \fn Q3ValueList::Q3ValueList()
|
|---|
| 154 |
|
|---|
| 155 | Constructs an empty list.
|
|---|
| 156 | */
|
|---|
| 157 |
|
|---|
| 158 | /*!
|
|---|
| 159 | \fn Q3ValueList::Q3ValueList( const Q3ValueList<T>& l )
|
|---|
| 160 | \fn Q3ValueList::Q3ValueList( const QList<T>& l )
|
|---|
| 161 | \fn Q3ValueList::Q3ValueList( const QLinkedList<T>& l )
|
|---|
| 162 |
|
|---|
| 163 | Constructs a copy of \a l.
|
|---|
| 164 | */
|
|---|
| 165 |
|
|---|
| 166 | /*!
|
|---|
| 167 | \fn Q3ValueList::Q3ValueList( const std::list<T>& l )
|
|---|
| 168 |
|
|---|
| 169 | Contructs a copy of \a l.
|
|---|
| 170 |
|
|---|
| 171 | This constructor is provided for compatibility with STL
|
|---|
| 172 | containers.
|
|---|
| 173 | */
|
|---|
| 174 |
|
|---|
| 175 | /*!
|
|---|
| 176 | \fn Q3ValueList::~Q3ValueList()
|
|---|
| 177 |
|
|---|
| 178 | Destroys the list. References to the values in the list and all
|
|---|
| 179 | iterators of this list become invalidated. Note that it is
|
|---|
| 180 | impossible for an iterator to check whether or not it is valid:
|
|---|
| 181 | Q3ValueList is highly tuned for performance, not for error
|
|---|
| 182 | checking.
|
|---|
| 183 | */
|
|---|
| 184 |
|
|---|
| 185 | /*!
|
|---|
| 186 | \fn bool Q3ValueList::operator== ( const Q3ValueList<T>& l ) const
|
|---|
| 187 |
|
|---|
| 188 | Compares both lists.
|
|---|
| 189 |
|
|---|
| 190 | Returns TRUE if this list and \a l are equal; otherwise returns
|
|---|
| 191 | FALSE.
|
|---|
| 192 | */
|
|---|
| 193 |
|
|---|
| 194 | /*!
|
|---|
| 195 | \fn bool Q3ValueList::operator== ( const std::list<T>& l ) const
|
|---|
| 196 |
|
|---|
| 197 | \overload
|
|---|
| 198 |
|
|---|
| 199 | Returns TRUE if this list and \a l are equal; otherwise returns
|
|---|
| 200 | FALSE.
|
|---|
| 201 |
|
|---|
| 202 | This operator is provided for compatibility with STL containers.
|
|---|
| 203 | */
|
|---|
| 204 |
|
|---|
| 205 | /*!
|
|---|
| 206 | \fn Q3ValueList<T>& Q3ValueList::operator= ( const Q3ValueList<T>& l )
|
|---|
| 207 |
|
|---|
| 208 | Assigns \a l to this list and returns a reference to this list.
|
|---|
| 209 |
|
|---|
| 210 | All iterators of the current list become invalidated by this
|
|---|
| 211 | operation. The cost of such an assignment is O(1) since Q3ValueList
|
|---|
| 212 | is implicitly shared.
|
|---|
| 213 | */
|
|---|
| 214 |
|
|---|
| 215 | /*!
|
|---|
| 216 | \fn Q3ValueList<T>& Q3ValueList::operator= ( const QList<T>& l )
|
|---|
| 217 |
|
|---|
| 218 | Assigns \a l to this list and returns a reference to this list.
|
|---|
| 219 |
|
|---|
| 220 | All iterators of the current list become invalidated by this
|
|---|
| 221 | operation.
|
|---|
| 222 | */
|
|---|
| 223 |
|
|---|
| 224 | /*!
|
|---|
| 225 | \fn Q3ValueList<T>& Q3ValueList::operator= ( const std::list<T>& l )
|
|---|
| 226 |
|
|---|
| 227 | \overload
|
|---|
| 228 |
|
|---|
| 229 | Assigns the contents of \a l to the list.
|
|---|
| 230 |
|
|---|
| 231 | All iterators of the current list become invalidated by this
|
|---|
| 232 | operation.
|
|---|
| 233 | */
|
|---|
| 234 |
|
|---|
| 235 | /*!
|
|---|
| 236 | \fn bool Q3ValueList::operator!= ( const Q3ValueList<T>& l ) const
|
|---|
| 237 |
|
|---|
| 238 | Compares both lists.
|
|---|
| 239 |
|
|---|
| 240 | Returns TRUE if this list and \a l are unequal; otherwise returns
|
|---|
| 241 | FALSE.
|
|---|
| 242 | */
|
|---|
| 243 |
|
|---|
| 244 | /*!
|
|---|
| 245 | \fn iterator Q3ValueList::insert( typename Q3ValueList<T>::Iterator it, const T& x )
|
|---|
| 246 |
|
|---|
| 247 | Inserts the value \a x in front of the item pointed to by the
|
|---|
| 248 | iterator, \a it.
|
|---|
| 249 |
|
|---|
| 250 | Returns an iterator pointing at the inserted item.
|
|---|
| 251 |
|
|---|
| 252 | \sa append(), prepend()
|
|---|
| 253 | */
|
|---|
| 254 |
|
|---|
| 255 | /*!
|
|---|
| 256 | \fn uint Q3ValueList::remove( const T& x )
|
|---|
| 257 |
|
|---|
| 258 | \overload
|
|---|
| 259 |
|
|---|
| 260 | Removes all items that have value \a x and returns the number of
|
|---|
| 261 | removed items.
|
|---|
| 262 | */
|
|---|
| 263 |
|
|---|
| 264 | /*!
|
|---|
| 265 | \fn QDataStream& operator>>( QDataStream& s, Q3ValueList<T>& l )
|
|---|
| 266 |
|
|---|
| 267 | \relates Q3ValueList
|
|---|
| 268 |
|
|---|
| 269 | Reads a list, \a l, from the stream \a s. The type T stored in the
|
|---|
| 270 | list must implement the streaming operator.
|
|---|
| 271 | */
|
|---|
| 272 |
|
|---|
| 273 | /*!
|
|---|
| 274 | \fn QDataStream& operator<<( QDataStream& s, const Q3ValueList<T>& l )
|
|---|
| 275 |
|
|---|
| 276 | \overload
|
|---|
| 277 | \relates Q3ValueList
|
|---|
| 278 |
|
|---|
| 279 | Writes a list, \a l, to the stream \a s. The type T stored in the
|
|---|
| 280 | list must implement the streaming operator.
|
|---|
| 281 | */
|
|---|
| 282 |
|
|---|
| 283 | /*!
|
|---|
| 284 | \fn void Q3ValueList::insert( typename Q3ValueList<T>::Iterator pos,
|
|---|
| 285 | typename Q3ValueList<T>::size_type n, const T& x )
|
|---|
| 286 |
|
|---|
| 287 | \overload
|
|---|
| 288 |
|
|---|
| 289 | Inserts \a n copies of \a x before position \a pos.
|
|---|
| 290 | */
|
|---|
| 291 |
|
|---|
| 292 | /*!
|
|---|
| 293 | \fn Q3ValueList<T>& Q3ValueList::operator<< ( const T& x )
|
|---|
| 294 |
|
|---|
| 295 | Adds the value \a x to the end of the list.
|
|---|
| 296 |
|
|---|
| 297 | Returns a reference to the list.
|
|---|
| 298 | */
|
|---|
| 299 |
|
|---|
| 300 | /*!
|
|---|
| 301 | \fn const T& Q3ValueList::operator[] ( typename Q3ValueList<T>::size_type i ) const
|
|---|
| 302 |
|
|---|
| 303 | Returns a const reference to the item with index \a i in the list.
|
|---|
| 304 | It is up to you to check whether this item really exists. You can
|
|---|
| 305 | do that easily with the count() function. However this operator
|
|---|
| 306 | does not check whether \a i is in range and will deliver undefined
|
|---|
| 307 | results if it does not exist.
|
|---|
| 308 |
|
|---|
| 309 | \warning This function uses a linear search and can be extremely
|
|---|
| 310 | slow for large lists. Q3ValueList is not optimized for random item
|
|---|
| 311 | access. If you need random access use a different container, such
|
|---|
| 312 | as Q3ValueVector.
|
|---|
| 313 | */
|
|---|
| 314 |
|
|---|
| 315 | /*!
|
|---|
| 316 | \fn T& Q3ValueList::operator[] ( typename Q3ValueList<T>::size_type i )
|
|---|
| 317 |
|
|---|
| 318 | \overload
|
|---|
| 319 |
|
|---|
| 320 | Returns a non-const reference to the item with index \a i.
|
|---|
| 321 | */
|
|---|
| 322 |
|
|---|
| 323 | /*!
|
|---|
| 324 | \fn const_iterator Q3ValueList::at( typename Q3ValueList<T>::size_type i ) const
|
|---|
| 325 |
|
|---|
| 326 | Returns an iterator pointing to the item at position \a i in the
|
|---|
| 327 | list, or an undefined value if the index is out of range.
|
|---|
| 328 |
|
|---|
| 329 | \warning This function uses a linear search and can be extremely
|
|---|
| 330 | slow for large lists. Q3ValueList is not optimized for random item
|
|---|
| 331 | access. If you need random access use a different container, such
|
|---|
| 332 | as Q3ValueVector.
|
|---|
| 333 | */
|
|---|
| 334 |
|
|---|
| 335 | /*!
|
|---|
| 336 | \fn iterator Q3ValueList::at( typename Q3ValueList<T>::size_type i )
|
|---|
| 337 |
|
|---|
| 338 | \overload
|
|---|
| 339 |
|
|---|
| 340 | Returns an iterator pointing to the item at position \a i in the
|
|---|
| 341 | list, or an undefined value if the index is out of range.
|
|---|
| 342 |
|
|---|
| 343 | */
|
|---|
| 344 |
|
|---|
| 345 | /*!
|
|---|
| 346 | \fn iterator Q3ValueList::fromLast()
|
|---|
| 347 |
|
|---|
| 348 | \overload
|
|---|
| 349 |
|
|---|
| 350 | Returns an iterator to the last item in the list, or end() if
|
|---|
| 351 | there is no last item.
|
|---|
| 352 |
|
|---|
| 353 | Use the end() function instead. For example:
|
|---|
| 354 |
|
|---|
| 355 | \snippet doc/src/snippets/code/doc_src_q3valuelist.qdoc 2
|
|---|
| 356 |
|
|---|
| 357 | */
|
|---|
| 358 |
|
|---|
| 359 | /*!
|
|---|
| 360 | \fn const_iterator Q3ValueList::fromLast() const
|
|---|
| 361 |
|
|---|
| 362 | Returns an iterator to the last item in the list, or end() if
|
|---|
| 363 | there is no last item.
|
|---|
| 364 |
|
|---|
| 365 | Use the end() function instead. For example:
|
|---|
| 366 |
|
|---|
| 367 | \snippet doc/src/snippets/code/doc_src_q3valuelist.qdoc 3
|
|---|
| 368 |
|
|---|
| 369 | */
|
|---|
| 370 |
|
|---|
| 371 | /*!
|
|---|
| 372 | \fn Q3ValueList<T> Q3ValueList::operator+( const Q3ValueList<T>& l ) const
|
|---|
| 373 |
|
|---|
| 374 | Creates a new list and fills it with the items of this list. Then
|
|---|
| 375 | the items of \a l are appended. Returns the new list.
|
|---|
| 376 | */
|
|---|
| 377 |
|
|---|
| 378 | /*!
|
|---|
| 379 | \fn Q3ValueList<T>& Q3ValueList::operator+= ( const Q3ValueList<T>& l )
|
|---|
| 380 |
|
|---|
| 381 | Appends the items of \a l to this list. Returns a reference to
|
|---|
| 382 | this list.
|
|---|
| 383 | */
|
|---|
| 384 |
|
|---|
| 385 | /*!
|
|---|
| 386 | \fn Q3ValueList<T>& Q3ValueList::operator+= ( const T& x )
|
|---|
| 387 |
|
|---|
| 388 | \overload
|
|---|
| 389 |
|
|---|
| 390 | Appends the value \a x to the list. Returns a reference to the
|
|---|
| 391 | list.
|
|---|
| 392 | */
|
|---|
| 393 |
|
|---|
| 394 | /*!
|
|---|
| 395 | \fn iterator Q3ValueList::append( const T& x )
|
|---|
| 396 |
|
|---|
| 397 | Inserts \a x at the end of the list.
|
|---|
| 398 |
|
|---|
| 399 | \sa insert(), prepend()
|
|---|
| 400 | */
|
|---|
| 401 |
|
|---|
| 402 | /*!
|
|---|
| 403 | \fn iterator Q3ValueList::prepend( const T& x )
|
|---|
| 404 |
|
|---|
| 405 | Inserts \a x at the beginning of the list.
|
|---|
| 406 |
|
|---|
| 407 | \sa insert(), append()
|
|---|
| 408 | */
|
|---|
| 409 |
|
|---|
| 410 | /*!
|
|---|
| 411 | \fn iterator Q3ValueList::remove( typename Q3ValueList<T>::Iterator it )
|
|---|
| 412 |
|
|---|
| 413 | Removes the item pointed to by \a it from the list. No iterators
|
|---|
| 414 | other than \a it or other iterators pointing at the same item as
|
|---|
| 415 | \a it are invalidated. Returns an iterator to the next item after
|
|---|
| 416 | \a it, or end() if there is no such item.
|
|---|
| 417 |
|
|---|
| 418 | \sa clear()
|
|---|
| 419 | */
|
|---|
| 420 |
|
|---|
| 421 | /*!
|
|---|
| 422 | \fn uint Q3ValueList::contains( const T& x ) const
|
|---|
| 423 |
|
|---|
| 424 | Returns the number of occurrences of the value \a x in the list.
|
|---|
| 425 | */
|
|---|
| 426 |
|
|---|
| 427 | /*!
|
|---|
| 428 | \class Q3ValueListIterator
|
|---|
| 429 | \brief The Q3ValueListIterator class provides an iterator for Q3ValueList.
|
|---|
| 430 | \compat
|
|---|
| 431 |
|
|---|
| 432 | An iterator is a class for accessing the items of a container
|
|---|
| 433 | class: a generalization of the index in an array. A pointer
|
|---|
| 434 | into a "const char *" and an index into an "int[]" are both
|
|---|
| 435 | iterators, and the general idea is to provide that functionality
|
|---|
| 436 | for any data structure.
|
|---|
| 437 |
|
|---|
| 438 | The Q3ValueListIterator class is an iterator for Q3ValueList
|
|---|
| 439 | instantiations. You can create the appropriate iterator type by
|
|---|
| 440 | using the \c iterator typedef provided by Q3ValueList.
|
|---|
| 441 |
|
|---|
| 442 | The only way to access the items in a Q3ValueList is to use an
|
|---|
| 443 | iterator.
|
|---|
| 444 |
|
|---|
| 445 | Example (see Q3ValueList for the complete code):
|
|---|
| 446 | \snippet doc/src/snippets/code/doc_src_q3valuelist.qdoc 4
|
|---|
| 447 |
|
|---|
| 448 | Q3ValueList is highly optimized for performance and memory usage.
|
|---|
| 449 | This means that you must be careful: Q3ValueList does not know
|
|---|
| 450 | about all its iterators and the iterators don't know to which list
|
|---|
| 451 | they belong. This makes things very fast, but if you're not
|
|---|
| 452 | careful, you can get spectacular bugs. Always make sure iterators
|
|---|
| 453 | are valid before dereferencing them or using them as parameters to
|
|---|
| 454 | generic algorithms in the STL.
|
|---|
| 455 |
|
|---|
| 456 | Using an invalid iterator is undefined (your application will
|
|---|
| 457 | probably crash). Many Qt functions return const value lists; to
|
|---|
| 458 | iterate over these you should make a copy and iterate over the
|
|---|
| 459 | copy.
|
|---|
| 460 |
|
|---|
| 461 | For every Iterator there is a ConstIterator. When accessing a
|
|---|
| 462 | Q3ValueList in a const environment or if the reference or pointer
|
|---|
| 463 | to the list is itself const, then you must use the ConstIterator.
|
|---|
| 464 | Its semantics are the same as the Iterator, but it only returns
|
|---|
| 465 | const references.
|
|---|
| 466 |
|
|---|
| 467 | \sa Q3ValueList, Q3ValueListConstIterator
|
|---|
| 468 | */
|
|---|
| 469 |
|
|---|
| 470 | /*!
|
|---|
| 471 | \fn Q3ValueListIterator::Q3ValueListIterator()
|
|---|
| 472 |
|
|---|
| 473 | Constructs an unitialized iterator.
|
|---|
| 474 | */
|
|---|
| 475 |
|
|---|
| 476 | /*!
|
|---|
| 477 | \fn Q3ValueListIterator::Q3ValueListIterator(const Q3ValueListIterator &o)
|
|---|
| 478 | \fn Q3ValueListIterator::Q3ValueListIterator(const typename QLinkedList<T>::iterator &o)
|
|---|
| 479 |
|
|---|
| 480 | Constucts a copy of iterator \a o.
|
|---|
| 481 | */
|
|---|
| 482 |
|
|---|
| 483 | /*!
|
|---|
| 484 | \class Q3ValueListConstIterator
|
|---|
| 485 | \brief The Q3ValueListConstIterator class provides a const iterator
|
|---|
| 486 | for Q3ValueList.
|
|---|
| 487 | \compat
|
|---|
| 488 |
|
|---|
| 489 | In contrast to Q3ValueListIterator, this class is used to iterate
|
|---|
| 490 | over a const list. It does not allow modification of the values of
|
|---|
| 491 | the list since that would break const semantics.
|
|---|
| 492 |
|
|---|
| 493 | You can create the appropriate const iterator type by using the \c
|
|---|
| 494 | const_iterator typedef provided by Q3ValueList.
|
|---|
| 495 |
|
|---|
| 496 | For more information on Q3ValueList iterators, see
|
|---|
| 497 | Q3ValueListIterator.
|
|---|
| 498 |
|
|---|
| 499 | \sa Q3ValueListIterator, Q3ValueList
|
|---|
| 500 | */
|
|---|
| 501 |
|
|---|
| 502 | /*!
|
|---|
| 503 | \fn Q3ValueListConstIterator::Q3ValueListConstIterator()
|
|---|
| 504 |
|
|---|
| 505 | Constructs an unitialized iterator.
|
|---|
| 506 | */
|
|---|
| 507 |
|
|---|
| 508 | /*!
|
|---|
| 509 | \fn Q3ValueListConstIterator::Q3ValueListConstIterator(const Q3ValueListConstIterator &o)
|
|---|
| 510 | \fn Q3ValueListConstIterator::Q3ValueListConstIterator(const typename QLinkedList<T>::const_iterator &o)
|
|---|
| 511 | \fn Q3ValueListConstIterator::Q3ValueListConstIterator(const typename QLinkedList<T>::iterator &o)
|
|---|
| 512 |
|
|---|
| 513 | Constructs a copy of iterator \a o.
|
|---|
| 514 | */
|
|---|
| 515 |
|
|---|
| 516 | /*!
|
|---|
| 517 | \typedef Q3ValueList::Iterator
|
|---|
| 518 |
|
|---|
| 519 | This iterator is an instantiation of Q3ValueListIterator for the
|
|---|
| 520 | same type as this Q3ValueList. In other words, if you instantiate
|
|---|
| 521 | Q3ValueList<int>, Iterator is a Q3ValueListIterator<int>. Several
|
|---|
| 522 | member function use it, such as Q3ValueList::begin(), which returns
|
|---|
| 523 | an iterator pointing to the first item in the list.
|
|---|
| 524 |
|
|---|
| 525 | Functionally, this is almost the same as ConstIterator. The only
|
|---|
| 526 | difference is that you cannot use ConstIterator for non-const
|
|---|
| 527 | operations, and that the compiler can often generate better code
|
|---|
| 528 | if you use ConstIterator.
|
|---|
| 529 |
|
|---|
| 530 | \sa Q3ValueListIterator ConstIterator
|
|---|
| 531 | */
|
|---|
| 532 |
|
|---|
| 533 | /*!
|
|---|
| 534 | \typedef Q3ValueList::ConstIterator
|
|---|
| 535 |
|
|---|
| 536 | This iterator is an instantiation of Q3ValueListConstIterator for
|
|---|
| 537 | the same type as this Q3ValueList. In other words, if you
|
|---|
| 538 | instantiate Q3ValueList<int>, ConstIterator is a
|
|---|
| 539 | Q3ValueListConstIterator<int>. Several member function use it, such
|
|---|
| 540 | as Q3ValueList::begin(), which returns an iterator pointing to the
|
|---|
| 541 | first item in the list.
|
|---|
| 542 |
|
|---|
| 543 | Functionally, this is almost the same as Iterator. The only
|
|---|
| 544 | difference is you cannot use ConstIterator for non-const
|
|---|
| 545 | operations, and that the compiler can often generate better code
|
|---|
| 546 | if you use ConstIterator.
|
|---|
| 547 |
|
|---|
| 548 | \sa Q3ValueListIterator Iterator
|
|---|
| 549 | */
|
|---|
| 550 |
|
|---|
| 551 | /*!
|
|---|
| 552 | \fn Q3ValueList::operator QList<T>() const
|
|---|
| 553 |
|
|---|
| 554 | Automatically converts a Q3ValueList<T> into a QList<T>.
|
|---|
| 555 | */
|
|---|