author | eckhart.koppen@nokia.com |
Wed, 31 Mar 2010 11:06:36 +0300 | |
changeset 7 | f7bc934e204c |
parent 0 | 1918ee327afb |
child 30 | 5dc02b23752f |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
7
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtCore module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include <new> |
|
43 |
#include "qlist.h" |
|
44 |
#include "qtools_p.h" |
|
45 |
#include <string.h> |
|
46 |
||
47 |
QT_BEGIN_NAMESPACE |
|
48 |
||
49 |
/* |
|
50 |
QList as an array-list combines the easy-of-use of a random |
|
51 |
access interface with fast list operations and the low memory |
|
52 |
management overhead of an array. Accessing elements by index, |
|
53 |
appending, prepending, and removing elements from both the front |
|
54 |
and the back all happen in constant time O(1). Inserting or |
|
55 |
removing elements at random index positions \ai happens in linear |
|
56 |
time, or more precisly in O(min{i,n-i}) <= O(n/2), with n being |
|
57 |
the number of elements in the list. |
|
58 |
*/ |
|
59 |
||
60 |
QListData::Data QListData::shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, 0, true, { 0 } }; |
|
61 |
||
62 |
static int grow(int size) |
|
63 |
{ |
|
64 |
// dear compiler: don't optimize me out. |
|
65 |
volatile int x = qAllocMore(size * sizeof(void *), QListData::DataHeaderSize) / sizeof(void *); |
|
66 |
return x; |
|
67 |
} |
|
68 |
||
69 |
#if QT_VERSION >= 0x050000 |
|
70 |
# error "Remove QListData::detach(), it is only required for binary compatibility for 4.0.x to 4.2.x" |
|
71 |
#endif |
|
72 |
QListData::Data *QListData::detach() |
|
73 |
{ |
|
74 |
Data *x = static_cast<Data *>(qMalloc(DataHeaderSize + d->alloc * sizeof(void *))); |
|
75 |
Q_CHECK_PTR(x); |
|
76 |
||
77 |
x->ref = 1; |
|
78 |
x->sharable = true; |
|
79 |
x->alloc = d->alloc; |
|
80 |
if (!x->alloc) { |
|
81 |
x->begin = 0; |
|
82 |
x->end = 0; |
|
83 |
} else { |
|
84 |
x->begin = d->begin; |
|
85 |
x->end = d->end; |
|
86 |
} |
|
87 |
||
88 |
qSwap(d, x); |
|
89 |
if (!x->ref.deref()) |
|
90 |
return x; |
|
91 |
return 0; |
|
92 |
} |
|
93 |
||
94 |
/*! |
|
95 |
* Detaches the QListData by reallocating new memory. |
|
96 |
* Returns the old (shared) data, it is up to the caller to deref() and free() |
|
97 |
* For the new data node_copy needs to be called. |
|
98 |
* |
|
99 |
* \internal |
|
100 |
*/ |
|
101 |
#if QT_VERSION >= 0x050000 |
|
102 |
# error "Remove QListData::detach2(), it is only required for binary compatibility for 4.3.x to 4.5.x" |
|
103 |
#endif |
|
104 |
QListData::Data *QListData::detach2() |
|
105 |
{ |
|
106 |
Data *x = d; |
|
107 |
Data* t = static_cast<Data *>(qMalloc(DataHeaderSize + x->alloc * sizeof(void *))); |
|
108 |
Q_CHECK_PTR(t); |
|
109 |
||
110 |
::memcpy(t, d, DataHeaderSize + d->alloc * sizeof(void *)); |
|
111 |
||
112 |
t->ref = 1; |
|
113 |
t->sharable = true; |
|
114 |
t->alloc = x->alloc; |
|
115 |
if (!t->alloc) { |
|
116 |
t->begin = 0; |
|
117 |
t->end = 0; |
|
118 |
} else { |
|
119 |
t->begin = x->begin; |
|
120 |
t->end = x->end; |
|
121 |
} |
|
122 |
d = t; |
|
123 |
||
124 |
return x; |
|
125 |
} |
|
126 |
||
127 |
/*! |
|
128 |
* Detaches the QListData by reallocating new memory. |
|
129 |
* Returns the old (shared) data, it is up to the caller to deref() and free() |
|
130 |
* For the new data node_copy needs to be called. |
|
131 |
* |
|
132 |
* \internal |
|
133 |
*/ |
|
134 |
QListData::Data *QListData::detach3() |
|
135 |
{ |
|
136 |
Data *x = d; |
|
137 |
Data* t = static_cast<Data *>(qMalloc(DataHeaderSize + x->alloc * sizeof(void *))); |
|
138 |
Q_CHECK_PTR(t); |
|
139 |
||
140 |
t->ref = 1; |
|
141 |
t->sharable = true; |
|
142 |
t->alloc = x->alloc; |
|
143 |
if (!t->alloc) { |
|
144 |
t->begin = 0; |
|
145 |
t->end = 0; |
|
146 |
} else { |
|
147 |
t->begin = x->begin; |
|
148 |
t->end = x->end; |
|
149 |
} |
|
150 |
d = t; |
|
151 |
||
152 |
return x; |
|
153 |
} |
|
154 |
||
155 |
void QListData::realloc(int alloc) |
|
156 |
{ |
|
157 |
Q_ASSERT(d->ref == 1); |
|
158 |
Data *x = static_cast<Data *>(qRealloc(d, DataHeaderSize + alloc * sizeof(void *))); |
|
159 |
Q_CHECK_PTR(x); |
|
160 |
||
161 |
d = x; |
|
162 |
d->alloc = alloc; |
|
163 |
if (!alloc) |
|
164 |
d->begin = d->end = 0; |
|
165 |
} |
|
166 |
||
167 |
// ensures that enough space is available to append one element |
|
168 |
void **QListData::append() |
|
169 |
{ |
|
170 |
Q_ASSERT(d->ref == 1); |
|
171 |
if (d->end == d->alloc) { |
|
172 |
int n = d->end - d->begin; |
|
173 |
if (d->begin > 2 * d->alloc / 3) { |
|
174 |
// we have enough space. Just not at the end -> move it. |
|
175 |
::memcpy(d->array + n, d->array + d->begin, n * sizeof(void *)); |
|
176 |
d->begin = n; |
|
177 |
d->end = n * 2; |
|
178 |
} else { |
|
179 |
realloc(grow(d->alloc + 1)); |
|
180 |
} |
|
181 |
} |
|
182 |
return d->array + d->end++; |
|
183 |
} |
|
184 |
||
185 |
// ensures that enough space is available to append the list |
|
186 |
#if QT_VERSION >= 0x050000 |
|
187 |
# error "Remove QListData::append(), it is only required for binary compatibility up to 4.5.x" |
|
188 |
#endif |
|
189 |
void **QListData::append(const QListData& l) |
|
190 |
{ |
|
191 |
Q_ASSERT(d->ref == 1); |
|
192 |
int e = d->end; |
|
193 |
int n = l.d->end - l.d->begin; |
|
194 |
if (n) { |
|
195 |
if (e + n > d->alloc) |
|
196 |
realloc(grow(e + l.d->end - l.d->begin)); |
|
197 |
::memcpy(d->array + d->end, l.d->array + l.d->begin, n*sizeof(void*)); |
|
198 |
d->end += n; |
|
199 |
} |
|
200 |
return d->array + e; |
|
201 |
} |
|
202 |
||
203 |
// ensures that enough space is available to append the list |
|
204 |
void **QListData::append2(const QListData& l) |
|
205 |
{ |
|
206 |
Q_ASSERT(d->ref == 1); |
|
207 |
int e = d->end; |
|
208 |
int n = l.d->end - l.d->begin; |
|
209 |
if (n) { |
|
210 |
if (e + n > d->alloc) |
|
7
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
0
diff
changeset
|
211 |
realloc(grow(e + n)); |
0 | 212 |
d->end += n; |
213 |
} |
|
214 |
return d->array + e; |
|
215 |
} |
|
216 |
||
217 |
void **QListData::prepend() |
|
218 |
{ |
|
219 |
Q_ASSERT(d->ref == 1); |
|
220 |
if (d->begin == 0) { |
|
221 |
if (d->end >= d->alloc / 3) |
|
222 |
realloc(grow(d->alloc + 1)); |
|
223 |
||
224 |
if (d->end < d->alloc / 3) |
|
225 |
d->begin = d->alloc - 2 * d->end; |
|
226 |
else |
|
227 |
d->begin = d->alloc - d->end; |
|
228 |
||
229 |
::memmove(d->array + d->begin, d->array, d->end * sizeof(void *)); |
|
230 |
d->end += d->begin; |
|
231 |
} |
|
232 |
return d->array + --d->begin; |
|
233 |
} |
|
234 |
||
235 |
void **QListData::insert(int i) |
|
236 |
{ |
|
237 |
Q_ASSERT(d->ref == 1); |
|
238 |
if (i <= 0) |
|
239 |
return prepend(); |
|
240 |
if (i >= d->end - d->begin) |
|
241 |
return append(); |
|
242 |
||
243 |
bool leftward = false; |
|
244 |
int size = d->end - d->begin; |
|
245 |
||
246 |
if (d->begin == 0) { |
|
247 |
if (d->end == d->alloc) { |
|
248 |
// If the array is full, we expand it and move some items rightward |
|
249 |
realloc(grow(d->alloc + 1)); |
|
250 |
} else { |
|
251 |
// If there is free space at the end of the array, we move some items rightward |
|
252 |
} |
|
253 |
} else { |
|
254 |
if (d->end == d->alloc) { |
|
255 |
// If there is free space at the beginning of the array, we move some items leftward |
|
256 |
leftward = true; |
|
257 |
} else { |
|
258 |
// If there is free space at both ends, we move as few items as possible |
|
259 |
leftward = (i < size - i); |
|
260 |
} |
|
261 |
} |
|
262 |
||
263 |
if (leftward) { |
|
264 |
--d->begin; |
|
265 |
::memmove(d->array + d->begin, d->array + d->begin + 1, i * sizeof(void *)); |
|
266 |
} else { |
|
267 |
::memmove(d->array + d->begin + i + 1, d->array + d->begin + i, |
|
268 |
(size - i) * sizeof(void *)); |
|
269 |
++d->end; |
|
270 |
} |
|
271 |
return d->array + d->begin + i; |
|
272 |
} |
|
273 |
||
274 |
void QListData::remove(int i) |
|
275 |
{ |
|
276 |
Q_ASSERT(d->ref == 1); |
|
277 |
i += d->begin; |
|
278 |
if (i - d->begin < d->end - i) { |
|
279 |
if (int offset = i - d->begin) |
|
280 |
::memmove(d->array + d->begin + 1, d->array + d->begin, offset * sizeof(void *)); |
|
281 |
d->begin++; |
|
282 |
} else { |
|
283 |
if (int offset = d->end - i - 1) |
|
284 |
::memmove(d->array + i, d->array + i + 1, offset * sizeof(void *)); |
|
285 |
d->end--; |
|
286 |
} |
|
287 |
} |
|
288 |
||
289 |
void QListData::remove(int i, int n) |
|
290 |
{ |
|
291 |
Q_ASSERT(d->ref == 1); |
|
292 |
i += d->begin; |
|
293 |
int middle = i + n/2; |
|
294 |
if (middle - d->begin < d->end - middle) { |
|
295 |
::memmove(d->array + d->begin + n, d->array + d->begin, |
|
296 |
(i - d->begin) * sizeof(void*)); |
|
297 |
d->begin += n; |
|
298 |
} else { |
|
299 |
::memmove(d->array + i, d->array + i + n, |
|
300 |
(d->end - i - n) * sizeof(void*)); |
|
301 |
d->end -= n; |
|
302 |
} |
|
303 |
} |
|
304 |
||
305 |
void QListData::move(int from, int to) |
|
306 |
{ |
|
307 |
Q_ASSERT(d->ref == 1); |
|
308 |
if (from == to) |
|
309 |
return; |
|
310 |
||
311 |
from += d->begin; |
|
312 |
to += d->begin; |
|
313 |
void *t = d->array[from]; |
|
314 |
||
315 |
if (from < to) { |
|
316 |
if (d->end == d->alloc || 3 * (to - from) < 2 * (d->end - d->begin)) { |
|
317 |
::memmove(d->array + from, d->array + from + 1, (to - from) * sizeof(void *)); |
|
318 |
} else { |
|
319 |
// optimization |
|
320 |
if (int offset = from - d->begin) |
|
321 |
::memmove(d->array + d->begin + 1, d->array + d->begin, offset * sizeof(void *)); |
|
322 |
if (int offset = d->end - (to + 1)) |
|
323 |
::memmove(d->array + to + 2, d->array + to + 1, offset * sizeof(void *)); |
|
324 |
++d->begin; |
|
325 |
++d->end; |
|
326 |
++to; |
|
327 |
} |
|
328 |
} else { |
|
329 |
if (d->begin == 0 || 3 * (from - to) < 2 * (d->end - d->begin)) { |
|
330 |
::memmove(d->array + to + 1, d->array + to, (from - to) * sizeof(void *)); |
|
331 |
} else { |
|
332 |
// optimization |
|
333 |
if (int offset = to - d->begin) |
|
334 |
::memmove(d->array + d->begin - 1, d->array + d->begin, offset * sizeof(void *)); |
|
335 |
if (int offset = d->end - (from + 1)) |
|
336 |
::memmove(d->array + from, d->array + from + 1, offset * sizeof(void *)); |
|
337 |
--d->begin; |
|
338 |
--d->end; |
|
339 |
--to; |
|
340 |
} |
|
341 |
} |
|
342 |
d->array[to] = t; |
|
343 |
} |
|
344 |
||
345 |
void **QListData::erase(void **xi) |
|
346 |
{ |
|
347 |
Q_ASSERT(d->ref == 1); |
|
348 |
int i = xi - (d->array + d->begin); |
|
349 |
remove(i); |
|
350 |
return d->array + d->begin + i; |
|
351 |
} |
|
352 |
||
353 |
/*! \class QList |
|
354 |
\brief The QList class is a template class that provides lists. |
|
355 |
||
356 |
\ingroup tools |
|
357 |
\ingroup shared |
|
358 |
||
359 |
\reentrant |
|
360 |
||
361 |
QList\<T\> is one of Qt's generic \l{container classes}. It |
|
362 |
stores a list of values and provides fast index-based access as |
|
363 |
well as fast insertions and removals. |
|
364 |
||
365 |
QList\<T\>, QLinkedList\<T\>, and QVector\<T\> provide similar |
|
366 |
functionality. Here's an overview: |
|
367 |
||
368 |
\list |
|
369 |
\i For most purposes, QList is the right class to use. Its |
|
370 |
index-based API is more convenient than QLinkedList's |
|
371 |
iterator-based API, and it is usually faster than |
|
372 |
QVector because of the way it stores its items in |
|
373 |
memory. It also expands to less code in your executable. |
|
374 |
\i If you need a real linked list, with guarantees of \l{constant |
|
375 |
time} insertions in the middle of the list and iterators to |
|
376 |
items rather than indexes, use QLinkedList. |
|
377 |
\i If you want the items to occupy adjacent memory positions, |
|
378 |
use QVector. |
|
379 |
\endlist |
|
380 |
||
381 |
||
382 |
Internally, QList\<T\> is represented as an array of pointers to |
|
383 |
items of type T. If T is itself a pointer type or a basic type |
|
384 |
that is no larger than a pointer, or if T is one of Qt's \l{shared |
|
385 |
classes}, then QList\<T\> stores the items directly in the pointer |
|
386 |
array. For lists under a thousand items, this array representation |
|
387 |
allows for very fast insertions in the middle, and it allows |
|
388 |
index-based access. Furthermore, operations like prepend() and |
|
389 |
append() are very fast, because QList preallocates memory at both |
|
390 |
ends of its internal array. (See \l{Algorithmic Complexity} for |
|
391 |
details.) Note, however, that for unshared list items that are |
|
392 |
larger than a pointer, each append or insert of a new item |
|
393 |
requires allocating the new item on the heap, and this per item |
|
394 |
allocation might make QVector a better choice in cases that do |
|
395 |
lots of appending or inserting, since QVector allocates memory for |
|
396 |
its items in a single heap allocation. |
|
397 |
||
398 |
Note that the internal array only ever gets bigger over the life |
|
399 |
of the list. It never shrinks. The internal array is deallocated |
|
400 |
by the destructor and by the assignment operator, when one list |
|
401 |
is assigned to another. |
|
402 |
||
403 |
Here's an example of a QList that stores integers and |
|
404 |
a QList that stores QDate values: |
|
405 |
||
406 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 0 |
|
407 |
||
408 |
Qt includes a QStringList class that inherits QList\<QString\> |
|
409 |
and adds a few convenience functions, such as QStringList::join() |
|
410 |
and QStringList::find(). (QString::split() creates QStringLists |
|
411 |
from strings.) |
|
412 |
||
413 |
QList stores a list of items. The default constructor creates an |
|
414 |
empty list. To insert items into the list, you can use |
|
415 |
operator<<(): |
|
416 |
||
417 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 1 |
|
418 |
||
419 |
QList provides these basic functions to add, move, and remove |
|
420 |
items: insert(), replace(), removeAt(), move(), and swap(). In |
|
421 |
addition, it provides the following convenience functions: |
|
422 |
append(), prepend(), removeFirst(), and removeLast(). |
|
423 |
||
424 |
QList uses 0-based indexes, just like C++ arrays. To access the |
|
425 |
item at a particular index position, you can use operator[](). On |
|
426 |
non-const lists, operator[]() returns a reference to the item and |
|
427 |
can be used on the left side of an assignment: |
|
428 |
||
429 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 2 |
|
430 |
||
431 |
Because QList is implemented as an array of pointers, this |
|
432 |
operation is very fast (\l{constant time}). For read-only access, |
|
433 |
an alternative syntax is to use at(): |
|
434 |
||
435 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 3 |
|
436 |
||
437 |
at() can be faster than operator[](), because it never causes a |
|
438 |
\l{deep copy} to occur. |
|
439 |
||
440 |
A common requirement is to remove an item from a list and do |
|
441 |
something with it. For this, QList provides takeAt(), takeFirst(), |
|
442 |
and takeLast(). Here's a loop that removes the items from a list |
|
443 |
one at a time and calls \c delete on them: |
|
444 |
||
445 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 4 |
|
446 |
||
447 |
Inserting and removing items at either ends of the list is very |
|
448 |
fast (\l{constant time} in most cases), because QList |
|
449 |
preallocates extra space on both sides of its internal buffer to |
|
450 |
allow for fast growth at both ends of the list. |
|
451 |
||
452 |
If you want to find all occurrences of a particular value in a |
|
453 |
list, use indexOf() or lastIndexOf(). The former searches forward |
|
454 |
starting from a given index position, the latter searches |
|
455 |
backward. Both return the index of a matching item if they find |
|
456 |
it; otherwise, they return -1. For example: |
|
457 |
||
458 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 5 |
|
459 |
||
460 |
If you simply want to check whether a list contains a particular |
|
461 |
value, use contains(). If you want to find out how many times a |
|
462 |
particular value occurs in the list, use count(). If you want to |
|
463 |
replace all occurrences of a particular value with another, use |
|
464 |
replace(). |
|
465 |
||
466 |
QList's value type must be an \l{assignable data type}. This |
|
467 |
covers most data types that are commonly used, but the compiler |
|
468 |
won't let you, for example, store a QWidget as a value; instead, |
|
469 |
store a QWidget *. A few functions have additional requirements; |
|
470 |
for example, indexOf() and lastIndexOf() expect the value type to |
|
471 |
support \c operator==(). These requirements are documented on a |
|
472 |
per-function basis. |
|
473 |
||
474 |
Like the other container classes, QList provides \l{Java-style |
|
475 |
iterators} (QListIterator and QMutableListIterator) and |
|
476 |
\l{STL-style iterators} (QList::const_iterator and |
|
477 |
QList::iterator). In practice, these are rarely used, because you |
|
478 |
can use indexes into the QList. QList is implemented in such a way |
|
479 |
that direct index-based access is just as fast as using iterators. |
|
480 |
||
481 |
QList does \e not support inserting, prepending, appending or |
|
482 |
replacing with references to its own values. Doing so will cause |
|
483 |
your application to abort with an error message. |
|
484 |
||
485 |
To make QList as efficient as possible, its member functions don't |
|
486 |
validate their input before using it. Except for isEmpty(), member |
|
487 |
functions always assume the list is \e not empty. Member functions |
|
488 |
that take index values as parameters always assume their index |
|
489 |
value parameters are in the valid range. This means QList member |
|
490 |
functions can fail. If you define QT_NO_DEBUG when you compile, |
|
491 |
failures will not be detected. If you \e don't define QT_NO_DEBUG, |
|
492 |
failures will be detected using Q_ASSERT() or Q_ASSERT_X() with an |
|
493 |
appropriate message. |
|
494 |
||
495 |
To avoid failures when your list can be empty, call isEmpty() |
|
496 |
before calling other member functions. If you must pass an index |
|
497 |
value that might not be in the valid range, check that it is less |
|
498 |
than the value returned by size() but \e not less than 0. |
|
499 |
||
500 |
\sa QListIterator, QMutableListIterator, QLinkedList, QVector |
|
501 |
*/ |
|
502 |
||
503 |
/*! |
|
504 |
\fn QList<T> QList<T>::mid(int pos, int length) const |
|
505 |
||
506 |
Returns a list whose elements are copied from this list, |
|
507 |
starting at position \a pos. If \a length is -1 (the default), all |
|
508 |
elements from \a pos are copied; otherwise \a length elements (or |
|
509 |
all remaining elements if there are less than \a length elements) |
|
510 |
are copied. |
|
511 |
*/ |
|
512 |
||
513 |
/*! \fn QList::QList() |
|
514 |
||
515 |
Constructs an empty list. |
|
516 |
*/ |
|
517 |
||
518 |
/*! \fn QList::QList(const QList<T> &other) |
|
519 |
||
520 |
Constructs a copy of \a other. |
|
521 |
||
522 |
This operation takes \l{constant time}, because QList is |
|
523 |
\l{implicitly shared}. This makes returning a QList from a |
|
524 |
function very fast. If a shared instance is modified, it will be |
|
525 |
copied (copy-on-write), and that takes \l{linear time}. |
|
526 |
||
527 |
\sa operator=() |
|
528 |
*/ |
|
529 |
||
530 |
/*! \fn QList::~QList() |
|
531 |
||
532 |
Destroys the list. References to the values in the list and all |
|
533 |
iterators of this list become invalid. |
|
534 |
*/ |
|
535 |
||
536 |
/*! \fn QList<T> &QList::operator=(const QList<T> &other) |
|
537 |
||
538 |
Assigns \a other to this list and returns a reference to this |
|
539 |
list. |
|
540 |
*/ |
|
541 |
||
542 |
/*! \fn bool QList::operator==(const QList<T> &other) const |
|
543 |
||
544 |
Returns true if \a other is equal to this list; otherwise returns |
|
545 |
false. |
|
546 |
||
547 |
Two lists are considered equal if they contain the same values in |
|
548 |
the same order. |
|
549 |
||
550 |
This function requires the value type to have an implementation of |
|
551 |
\c operator==(). |
|
552 |
||
553 |
\sa operator!=() |
|
554 |
*/ |
|
555 |
||
556 |
/*! \fn bool QList::operator!=(const QList<T> &other) const |
|
557 |
||
558 |
Returns true if \a other is not equal to this list; otherwise |
|
559 |
returns false. |
|
560 |
||
561 |
Two lists are considered equal if they contain the same values in |
|
562 |
the same order. |
|
563 |
||
564 |
This function requires the value type to have an implementation of |
|
565 |
\c operator==(). |
|
566 |
||
567 |
\sa operator==() |
|
568 |
*/ |
|
569 |
||
570 |
/*! |
|
571 |
\fn int QList::size() const |
|
572 |
||
573 |
Returns the number of items in the list. |
|
574 |
||
575 |
\sa isEmpty(), count() |
|
576 |
*/ |
|
577 |
||
578 |
/*! \fn void QList::detach() |
|
579 |
||
580 |
\internal |
|
581 |
*/ |
|
582 |
||
583 |
/*! \fn void QList::detachShared() |
|
584 |
||
585 |
\internal |
|
586 |
||
587 |
like detach(), but does nothing if we're shared_null. |
|
588 |
This prevents needless mallocs, and makes QList more exception safe |
|
589 |
in case of cleanup work done in destructors on empty lists. |
|
590 |
*/ |
|
591 |
||
592 |
/*! \fn bool QList::isDetached() const |
|
593 |
||
594 |
\internal |
|
595 |
*/ |
|
596 |
||
597 |
/*! \fn void QList::setSharable(bool sharable) |
|
598 |
||
599 |
\internal |
|
600 |
*/ |
|
601 |
||
602 |
/*! \fn bool QList::isEmpty() const |
|
603 |
||
604 |
Returns true if the list contains no items; otherwise returns |
|
605 |
false. |
|
606 |
||
607 |
\sa size() |
|
608 |
*/ |
|
609 |
||
610 |
/*! \fn void QList::clear() |
|
611 |
||
612 |
Removes all items from the list. |
|
613 |
||
614 |
\sa removeAll() |
|
615 |
*/ |
|
616 |
||
617 |
/*! \fn const T &QList::at(int i) const |
|
618 |
||
619 |
Returns the item at index position \a i in the list. \a i must be |
|
620 |
a valid index position in the list (i.e., 0 <= \a i < size()). |
|
621 |
||
622 |
This function is very fast (\l{constant time}). |
|
623 |
||
624 |
\sa value(), operator[]() |
|
625 |
*/ |
|
626 |
||
627 |
/*! \fn T &QList::operator[](int i) |
|
628 |
||
629 |
Returns the item at index position \a i as a modifiable reference. |
|
630 |
\a i must be a valid index position in the list (i.e., 0 <= \a i < |
|
631 |
size()). |
|
632 |
||
633 |
This function is very fast (\l{constant time}). |
|
634 |
||
635 |
\sa at(), value() |
|
636 |
*/ |
|
637 |
||
638 |
/*! \fn const T &QList::operator[](int i) const |
|
639 |
||
640 |
\overload |
|
641 |
||
642 |
Same as at(). |
|
643 |
*/ |
|
644 |
||
645 |
/*! \fn void QList::append(const T &value) |
|
646 |
||
647 |
Inserts \a value at the end of the list. |
|
648 |
||
649 |
Example: |
|
650 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 6 |
|
651 |
||
652 |
This is the same as list.insert(size(), \a value). |
|
653 |
||
654 |
This operation is typically very fast (\l{constant time}), |
|
655 |
because QList preallocates extra space on both sides of its |
|
656 |
internal buffer to allow for fast growth at both ends of the |
|
657 |
list. |
|
658 |
||
659 |
\sa operator<<(), prepend(), insert() |
|
660 |
*/ |
|
661 |
||
662 |
/*! \fn void QList::append(const QList<T> &value) |
|
663 |
||
664 |
\overload |
|
665 |
||
666 |
\since 4.5 |
|
667 |
||
668 |
Appends the items of the \a value list to this list. |
|
669 |
||
670 |
\sa operator<<(), operator+=() |
|
671 |
*/ |
|
672 |
||
673 |
/*! \fn void QList::prepend(const T &value) |
|
674 |
||
675 |
Inserts \a value at the beginning of the list. |
|
676 |
||
677 |
Example: |
|
678 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 7 |
|
679 |
||
680 |
This is the same as list.insert(0, \a value). |
|
681 |
||
682 |
This operation is usually very fast (\l{constant time}), because |
|
683 |
QList preallocates extra space on both sides of its internal |
|
684 |
buffer to allow for fast growth at both ends of the list. |
|
685 |
||
686 |
\sa append(), insert() |
|
687 |
*/ |
|
688 |
||
689 |
/*! \fn void QList::insert(int i, const T &value) |
|
690 |
||
691 |
Inserts \a value at index position \a i in the list. If \a i |
|
692 |
is 0, the value is prepended to the list. If \a i is size(), the |
|
693 |
value is appended to the list. |
|
694 |
||
695 |
Example: |
|
696 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 8 |
|
697 |
||
698 |
\sa append(), prepend(), replace(), removeAt() |
|
699 |
*/ |
|
700 |
||
701 |
/*! \fn QList::iterator QList::insert(iterator before, const T &value) |
|
702 |
||
703 |
\overload |
|
704 |
||
705 |
Inserts \a value in front of the item pointed to by the |
|
706 |
iterator \a before. Returns an iterator pointing at the inserted |
|
707 |
item. Note that the iterator passed to the function will be |
|
708 |
invalid after the call; the returned iterator should be used |
|
709 |
instead. |
|
710 |
*/ |
|
711 |
||
712 |
/*! \fn void QList::replace(int i, const T &value) |
|
713 |
||
714 |
Replaces the item at index position \a i with \a value. \a i must |
|
715 |
be a valid index position in the list (i.e., 0 <= \a i < size()). |
|
716 |
||
717 |
\sa operator[](), removeAt() |
|
718 |
*/ |
|
719 |
||
720 |
/*! |
|
721 |
\fn int QList::removeAll(const T &value) |
|
722 |
||
723 |
Removes all occurrences of \a value in the list and returns the |
|
724 |
number of entries removed. |
|
725 |
||
726 |
Example: |
|
727 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 9 |
|
728 |
||
729 |
This function requires the value type to have an implementation of |
|
730 |
\c operator==(). |
|
731 |
||
732 |
\sa removeOne(), removeAt(), takeAt(), replace() |
|
733 |
*/ |
|
734 |
||
735 |
/*! |
|
736 |
\fn bool QList::removeOne(const T &value) |
|
737 |
\since 4.4 |
|
738 |
||
739 |
Removes the first occurrence of \a value in the list and returns |
|
740 |
true on success; otherwise returns false. |
|
741 |
||
742 |
Example: |
|
743 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 10 |
|
744 |
||
745 |
This function requires the value type to have an implementation of |
|
746 |
\c operator==(). |
|
747 |
||
748 |
\sa removeAll(), removeAt(), takeAt(), replace() |
|
749 |
*/ |
|
750 |
||
751 |
/*! \fn void QList::removeAt(int i) |
|
752 |
||
753 |
Removes the item at index position \a i. \a i must be a valid |
|
754 |
index position in the list (i.e., 0 <= \a i < size()). |
|
755 |
||
756 |
\sa takeAt(), removeFirst(), removeLast(), removeOne() |
|
757 |
*/ |
|
758 |
||
759 |
/*! \fn T QList::takeAt(int i) |
|
760 |
||
761 |
Removes the item at index position \a i and returns it. \a i must |
|
762 |
be a valid index position in the list (i.e., 0 <= \a i < size()). |
|
763 |
||
764 |
If you don't use the return value, removeAt() is more efficient. |
|
765 |
||
766 |
\sa removeAt(), takeFirst(), takeLast() |
|
767 |
*/ |
|
768 |
||
769 |
/*! \fn T QList::takeFirst() |
|
770 |
||
771 |
Removes the first item in the list and returns it. This is the |
|
772 |
same as takeAt(0). This function assumes the list is not empty. To |
|
773 |
avoid failure, call isEmpty() before calling this function. |
|
774 |
||
775 |
This operation is very fast (\l{constant time}), because QList |
|
776 |
preallocates extra space on both sides of its internal buffer to |
|
777 |
allow for fast growth at both ends of the list. |
|
778 |
||
779 |
If you don't use the return value, removeFirst() is more |
|
780 |
efficient. |
|
781 |
||
782 |
\sa takeLast(), takeAt(), removeFirst() |
|
783 |
*/ |
|
784 |
||
785 |
/*! \fn T QList::takeLast() |
|
786 |
||
787 |
Removes the last item in the list and returns it. This is the |
|
788 |
same as takeAt(size() - 1). This function assumes the list is |
|
789 |
not empty. To avoid failure, call isEmpty() before calling this |
|
790 |
function. |
|
791 |
||
792 |
This operation is very fast (\l{constant time}), because QList |
|
793 |
preallocates extra space on both sides of its internal buffer to |
|
794 |
allow for fast growth at both ends of the list. |
|
795 |
||
796 |
If you don't use the return value, removeLast() is more |
|
797 |
efficient. |
|
798 |
||
799 |
\sa takeFirst(), takeAt(), removeLast() |
|
800 |
*/ |
|
801 |
||
802 |
/*! \fn void QList::move(int from, int to) |
|
803 |
||
804 |
Moves the item at index position \a from to index position \a to. |
|
805 |
||
806 |
Example: |
|
807 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 11 |
|
808 |
||
809 |
This is the same as insert(\a{to}, takeAt(\a{from})).This function |
|
810 |
assumes that both \a from and \a to are at least 0 but less than |
|
811 |
size(). To avoid failure, test that both \a from and \a to are at |
|
812 |
least 0 and less than size(). |
|
813 |
||
814 |
\sa swap(), insert(), takeAt() |
|
815 |
*/ |
|
816 |
||
817 |
/*! \fn void QList::swap(int i, int j) |
|
818 |
||
819 |
Exchange the item at index position \a i with the item at index |
|
820 |
position \a j. This function assumes that both \a i and \a j are |
|
821 |
at least 0 but less than size(). To avoid failure, test that both |
|
822 |
\a i and \a j are at least 0 and less than size(). |
|
823 |
||
824 |
Example: |
|
825 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 12 |
|
826 |
||
827 |
\sa move() |
|
828 |
*/ |
|
829 |
||
830 |
/*! \fn int QList::indexOf(const T &value, int from = 0) const |
|
831 |
||
832 |
Returns the index position of the first occurrence of \a value in |
|
833 |
the list, searching forward from index position \a from. Returns |
|
834 |
-1 if no item matched. |
|
835 |
||
836 |
Example: |
|
837 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 13 |
|
838 |
||
839 |
This function requires the value type to have an implementation of |
|
840 |
\c operator==(). |
|
841 |
||
842 |
Note that QList uses 0-based indexes, just like C++ arrays. Negative |
|
843 |
indexes are not supported with the exception of the value mentioned |
|
844 |
above. |
|
845 |
||
846 |
\sa lastIndexOf(), contains() |
|
847 |
*/ |
|
848 |
||
849 |
/*! \fn int QList::lastIndexOf(const T &value, int from = -1) const |
|
850 |
||
851 |
Returns the index position of the last occurrence of \a value in |
|
852 |
the list, searching backward from index position \a from. If \a |
|
853 |
from is -1 (the default), the search starts at the last item. |
|
854 |
Returns -1 if no item matched. |
|
855 |
||
856 |
Example: |
|
857 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 14 |
|
858 |
||
859 |
This function requires the value type to have an implementation of |
|
860 |
\c operator==(). |
|
861 |
||
862 |
Note that QList uses 0-based indexes, just like C++ arrays. Negative |
|
863 |
indexes are not supported with the exception of the value mentioned |
|
864 |
above. |
|
865 |
||
866 |
\sa indexOf() |
|
867 |
*/ |
|
868 |
||
869 |
/*! \fn QBool QList::contains(const T &value) const |
|
870 |
||
871 |
Returns true if the list contains an occurrence of \a value; |
|
872 |
otherwise returns false. |
|
873 |
||
874 |
This function requires the value type to have an implementation of |
|
875 |
\c operator==(). |
|
876 |
||
877 |
\sa indexOf(), count() |
|
878 |
*/ |
|
879 |
||
880 |
/*! \fn int QList::count(const T &value) const |
|
881 |
||
882 |
Returns the number of occurrences of \a value in the list. |
|
883 |
||
884 |
This function requires the value type to have an implementation of |
|
885 |
\c operator==(). |
|
886 |
||
887 |
\sa contains(), indexOf() |
|
888 |
*/ |
|
889 |
||
890 |
/*! \fn bool QList::startsWith(const T &value) const |
|
891 |
\since 4.5 |
|
892 |
||
893 |
Returns true if this list is not empty and its first |
|
894 |
item is equal to \a value; otherwise returns false. |
|
895 |
||
896 |
\sa isEmpty(), contains() |
|
897 |
*/ |
|
898 |
||
899 |
/*! \fn bool QList::endsWith(const T &value) const |
|
900 |
\since 4.5 |
|
901 |
||
902 |
Returns true if this list is not empty and its last |
|
903 |
item is equal to \a value; otherwise returns false. |
|
904 |
||
905 |
\sa isEmpty(), contains() |
|
906 |
*/ |
|
907 |
||
908 |
/*! \fn QList::iterator QList::begin() |
|
909 |
||
910 |
Returns an \l{STL-style iterator} pointing to the first item in |
|
911 |
the list. |
|
912 |
||
913 |
\sa constBegin(), end() |
|
914 |
*/ |
|
915 |
||
916 |
/*! \fn QList::const_iterator QList::begin() const |
|
917 |
||
918 |
\overload |
|
919 |
*/ |
|
920 |
||
921 |
/*! \fn QList::const_iterator QList::constBegin() const |
|
922 |
||
923 |
Returns a const \l{STL-style iterator} pointing to the first item |
|
924 |
in the list. |
|
925 |
||
926 |
\sa begin(), constEnd() |
|
927 |
*/ |
|
928 |
||
929 |
/*! \fn QList::iterator QList::end() |
|
930 |
||
931 |
Returns an \l{STL-style iterator} pointing to the imaginary item |
|
932 |
after the last item in the list. |
|
933 |
||
934 |
\sa begin(), constEnd() |
|
935 |
*/ |
|
936 |
||
937 |
/*! \fn const_iterator QList::end() const |
|
938 |
||
939 |
\overload |
|
940 |
*/ |
|
941 |
||
942 |
/*! \fn QList::const_iterator QList::constEnd() const |
|
943 |
||
944 |
Returns a const \l{STL-style iterator} pointing to the imaginary |
|
945 |
item after the last item in the list. |
|
946 |
||
947 |
\sa constBegin(), end() |
|
948 |
*/ |
|
949 |
||
950 |
/*! \fn QList::iterator QList::erase(iterator pos) |
|
951 |
||
952 |
Removes the item associated with the iterator \a pos from the |
|
953 |
list, and returns an iterator to the next item in the list (which |
|
954 |
may be end()). |
|
955 |
||
956 |
\sa insert(), removeAt() |
|
957 |
*/ |
|
958 |
||
959 |
/*! \fn QList::iterator QList::erase(iterator begin, iterator end) |
|
960 |
||
961 |
\overload |
|
962 |
||
963 |
Removes all the items from \a begin up to (but not including) \a |
|
964 |
end. Returns an iterator to the same item that \a end referred to |
|
965 |
before the call. |
|
966 |
*/ |
|
967 |
||
968 |
/*! \typedef QList::Iterator |
|
969 |
||
970 |
Qt-style synonym for QList::iterator. |
|
971 |
*/ |
|
972 |
||
973 |
/*! \typedef QList::ConstIterator |
|
974 |
||
975 |
Qt-style synonym for QList::const_iterator. |
|
976 |
*/ |
|
977 |
||
978 |
/*! |
|
979 |
\typedef QList::size_type |
|
980 |
||
981 |
Typedef for int. Provided for STL compatibility. |
|
982 |
*/ |
|
983 |
||
984 |
/*! |
|
985 |
\typedef QList::value_type |
|
986 |
||
987 |
Typedef for T. Provided for STL compatibility. |
|
988 |
*/ |
|
989 |
||
990 |
/*! |
|
991 |
\typedef QList::difference_type |
|
992 |
||
993 |
Typedef for ptrdiff_t. Provided for STL compatibility. |
|
994 |
*/ |
|
995 |
||
996 |
/*! |
|
997 |
\typedef QList::pointer |
|
998 |
||
999 |
Typedef for T *. Provided for STL compatibility. |
|
1000 |
*/ |
|
1001 |
||
1002 |
/*! |
|
1003 |
\typedef QList::const_pointer |
|
1004 |
||
1005 |
Typedef for const T *. Provided for STL compatibility. |
|
1006 |
*/ |
|
1007 |
||
1008 |
/*! |
|
1009 |
\typedef QList::reference |
|
1010 |
||
1011 |
Typedef for T &. Provided for STL compatibility. |
|
1012 |
*/ |
|
1013 |
||
1014 |
/*! |
|
1015 |
\typedef QList::const_reference |
|
1016 |
||
1017 |
Typedef for const T &. Provided for STL compatibility. |
|
1018 |
*/ |
|
1019 |
||
1020 |
/*! \fn int QList::count() const |
|
1021 |
||
1022 |
Returns the number of items in the list. This is effectively the |
|
1023 |
same as size(). |
|
1024 |
*/ |
|
1025 |
||
1026 |
/*! \fn int QList::length() const |
|
1027 |
\since 4.5 |
|
1028 |
||
1029 |
This function is identical to count(). |
|
1030 |
||
1031 |
\sa count() |
|
1032 |
*/ |
|
1033 |
||
1034 |
/*! \fn T& QList::first() |
|
1035 |
||
1036 |
Returns a reference to the first item in the list. The list must |
|
1037 |
not be empty. If the list can be empty, call isEmpty() before |
|
1038 |
calling this function. |
|
1039 |
||
1040 |
\sa last(), isEmpty() |
|
1041 |
*/ |
|
1042 |
||
1043 |
/*! \fn const T& QList::first() const |
|
1044 |
||
1045 |
\overload |
|
1046 |
*/ |
|
1047 |
||
1048 |
/*! \fn T& QList::last() |
|
1049 |
||
1050 |
Returns a reference to the last item in the list. The list must |
|
1051 |
not be empty. If the list can be empty, call isEmpty() before |
|
1052 |
calling this function. |
|
1053 |
||
1054 |
\sa first(), isEmpty() |
|
1055 |
*/ |
|
1056 |
||
1057 |
/*! \fn const T& QList::last() const |
|
1058 |
||
1059 |
\overload |
|
1060 |
*/ |
|
1061 |
||
1062 |
/*! \fn void QList::removeFirst() |
|
1063 |
||
1064 |
Removes the first item in the list. Calling this function is |
|
1065 |
equivalent to calling removeAt(0). The list must not be empty. If |
|
1066 |
the list can be empty, call isEmpty() before calling this |
|
1067 |
function. |
|
1068 |
||
1069 |
\sa removeAt(), takeFirst() |
|
1070 |
*/ |
|
1071 |
||
1072 |
/*! \fn void QList::removeLast() |
|
1073 |
||
1074 |
Removes the last item in the list. Calling this function is |
|
1075 |
equivalent to calling removeAt(size() - 1). The list must not be |
|
1076 |
empty. If the list can be empty, call isEmpty() before calling |
|
1077 |
this function. |
|
1078 |
||
1079 |
\sa removeAt(), takeLast() |
|
1080 |
*/ |
|
1081 |
||
1082 |
/*! \fn T QList::value(int i) const |
|
1083 |
||
1084 |
Returns the value at index position \a i in the list. |
|
1085 |
||
1086 |
If the index \a i is out of bounds, the function returns a |
|
1087 |
\l{default-constructed value}. If you are certain that the index |
|
1088 |
is going to be within bounds, you can use at() instead, which is |
|
1089 |
slightly faster. |
|
1090 |
||
1091 |
\sa at(), operator[]() |
|
1092 |
*/ |
|
1093 |
||
1094 |
/*! \fn T QList::value(int i, const T &defaultValue) const |
|
1095 |
||
1096 |
\overload |
|
1097 |
||
1098 |
If the index \a i is out of bounds, the function returns |
|
1099 |
\a defaultValue. |
|
1100 |
*/ |
|
1101 |
||
1102 |
/*! \fn void QList::push_back(const T &value) |
|
1103 |
||
1104 |
This function is provided for STL compatibility. It is equivalent |
|
1105 |
to \l{QList::append()}{append(\a value)}. |
|
1106 |
*/ |
|
1107 |
||
1108 |
/*! \fn void QList::push_front(const T &value) |
|
1109 |
||
1110 |
This function is provided for STL compatibility. It is equivalent |
|
1111 |
to \l{QList::prepend()}{prepend(\a value)}. |
|
1112 |
*/ |
|
1113 |
||
1114 |
/*! \fn T& QList::front() |
|
1115 |
||
1116 |
This function is provided for STL compatibility. It is equivalent |
|
1117 |
to first(). The list must not be empty. If the list can be empty, |
|
1118 |
call isEmpty() before calling this function. |
|
1119 |
*/ |
|
1120 |
||
1121 |
/*! \fn const T& QList::front() const |
|
1122 |
||
1123 |
\overload |
|
1124 |
*/ |
|
1125 |
||
1126 |
/*! \fn T& QList::back() |
|
1127 |
||
1128 |
This function is provided for STL compatibility. It is equivalent |
|
1129 |
to last(). The list must not be empty. If the list can be empty, |
|
1130 |
call isEmpty() before calling this function. |
|
1131 |
*/ |
|
1132 |
||
1133 |
/*! \fn const T& QList::back() const |
|
1134 |
||
1135 |
\overload |
|
1136 |
*/ |
|
1137 |
||
1138 |
/*! \fn void QList::pop_front() |
|
1139 |
||
1140 |
This function is provided for STL compatibility. It is equivalent |
|
1141 |
to removeFirst(). The list must not be empty. If the list can be |
|
1142 |
empty, call isEmpty() before calling this function. |
|
1143 |
*/ |
|
1144 |
||
1145 |
/*! \fn void QList::pop_back() |
|
1146 |
||
1147 |
This function is provided for STL compatibility. It is equivalent |
|
1148 |
to removeLast(). The list must not be empty. If the list can be |
|
1149 |
empty, call isEmpty() before calling this function. |
|
1150 |
*/ |
|
1151 |
||
1152 |
/*! \fn bool QList::empty() const |
|
1153 |
||
1154 |
This function is provided for STL compatibility. It is equivalent |
|
1155 |
to isEmpty() and returns true if the list is empty. |
|
1156 |
*/ |
|
1157 |
||
1158 |
/*! \fn QList<T> &QList::operator+=(const QList<T> &other) |
|
1159 |
||
1160 |
Appends the items of the \a other list to this list and returns a |
|
1161 |
reference to this list. |
|
1162 |
||
1163 |
\sa operator+(), append() |
|
1164 |
*/ |
|
1165 |
||
1166 |
/*! \fn void QList::operator+=(const T &value) |
|
1167 |
||
1168 |
\overload |
|
1169 |
||
1170 |
Appends \a value to the list. |
|
1171 |
||
1172 |
\sa append(), operator<<() |
|
1173 |
*/ |
|
1174 |
||
1175 |
/*! \fn QList<T> QList::operator+(const QList<T> &other) const |
|
1176 |
||
1177 |
Returns a list that contains all the items in this list followed |
|
1178 |
by all the items in the \a other list. |
|
1179 |
||
1180 |
\sa operator+=() |
|
1181 |
*/ |
|
1182 |
||
1183 |
/*! \fn QList<T> &QList::operator<<(const QList<T> &other) |
|
1184 |
||
1185 |
Appends the items of the \a other list to this list and returns a |
|
1186 |
reference to this list. |
|
1187 |
||
1188 |
\sa operator+=(), append() |
|
1189 |
*/ |
|
1190 |
||
1191 |
/*! \fn void QList::operator<<(const T &value) |
|
1192 |
||
1193 |
\overload |
|
1194 |
||
1195 |
Appends \a value to the list. |
|
1196 |
*/ |
|
1197 |
||
1198 |
/*! \class QList::iterator |
|
1199 |
\brief The QList::iterator class provides an STL-style non-const iterator for QList and QQueue. |
|
1200 |
||
1201 |
QList features both \l{STL-style iterators} and \l{Java-style |
|
1202 |
iterators}. The STL-style iterators are more low-level and more |
|
1203 |
cumbersome to use; on the other hand, they are slightly faster |
|
1204 |
and, for developers who already know STL, have the advantage of |
|
1205 |
familiarity. |
|
1206 |
||
1207 |
QList\<T\>::iterator allows you to iterate over a QList\<T\> (or |
|
1208 |
QQueue\<T\>) and to modify the list item associated with the |
|
1209 |
iterator. If you want to iterate over a const QList, use |
|
1210 |
QList::const_iterator instead. It is generally good practice to |
|
1211 |
use QList::const_iterator on a non-const QList as well, unless |
|
1212 |
you need to change the QList through the iterator. Const |
|
1213 |
iterators are slightly faster, and can improve code readability. |
|
1214 |
||
1215 |
The default QList::iterator constructor creates an uninitialized |
|
1216 |
iterator. You must initialize it using a QList function like |
|
1217 |
QList::begin(), QList::end(), or QList::insert() before you can |
|
1218 |
start iterating. Here's a typical loop that prints all the items |
|
1219 |
stored in a list: |
|
1220 |
||
1221 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 15 |
|
1222 |
||
1223 |
Let's see a few examples of things we can do with a |
|
1224 |
QList::iterator that we cannot do with a QList::const_iterator. |
|
1225 |
Here's an example that increments every value stored in a |
|
1226 |
QList\<int\> by 2: |
|
1227 |
||
1228 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 16 |
|
1229 |
||
1230 |
Most QList functions accept an integer index rather than an |
|
1231 |
iterator. For that reason, iterators are rarely useful in |
|
1232 |
connection with QList. One place where STL-style iterators do |
|
1233 |
make sense is as arguments to \l{generic algorithms}. |
|
1234 |
||
1235 |
For example, here's how to delete all the widgets stored in a |
|
1236 |
QList\<QWidget *\>: |
|
1237 |
||
1238 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 17 |
|
1239 |
||
1240 |
Multiple iterators can be used on the same list. However, be |
|
1241 |
aware that any non-const function call performed on the QList |
|
1242 |
will render all existing iterators undefined. If you need to keep |
|
1243 |
iterators over a long period of time, we recommend that you use |
|
1244 |
QLinkedList rather than QList. |
|
1245 |
||
1246 |
\sa QList::const_iterator, QMutableListIterator |
|
1247 |
*/ |
|
1248 |
||
1249 |
/*! \typedef QList::iterator::iterator_category |
|
1250 |
||
1251 |
A synonym for \e {std::random_access_iterator_tag} indicating |
|
1252 |
this iterator is a random access iterator. |
|
1253 |
*/ |
|
1254 |
||
1255 |
/*! \typedef QList::iterator::difference_type |
|
1256 |
||
1257 |
\internal |
|
1258 |
*/ |
|
1259 |
||
1260 |
/*! \typedef QList::iterator::value_type |
|
1261 |
||
1262 |
\internal |
|
1263 |
*/ |
|
1264 |
||
1265 |
/*! \typedef QList::iterator::pointer |
|
1266 |
||
1267 |
\internal |
|
1268 |
*/ |
|
1269 |
||
1270 |
/*! \typedef QList::iterator::reference |
|
1271 |
||
1272 |
\internal |
|
1273 |
*/ |
|
1274 |
||
1275 |
/*! \fn QList::iterator::iterator() |
|
1276 |
||
1277 |
Constructs an uninitialized iterator. |
|
1278 |
||
1279 |
Functions like operator*() and operator++() should not be called |
|
1280 |
on an uninitialized iterator. Use operator=() to assign a value |
|
1281 |
to it before using it. |
|
1282 |
||
1283 |
\sa QList::begin() QList::end() |
|
1284 |
*/ |
|
1285 |
||
1286 |
/*! \fn QList::iterator::iterator(Node *node) |
|
1287 |
||
1288 |
\internal |
|
1289 |
*/ |
|
1290 |
||
1291 |
/*! \fn QList::iterator::iterator(const iterator &other) |
|
1292 |
||
1293 |
Constructs a copy of \a other. |
|
1294 |
*/ |
|
1295 |
||
1296 |
/*! \fn T &QList::iterator::operator*() const |
|
1297 |
||
1298 |
Returns a modifiable reference to the current item. |
|
1299 |
||
1300 |
You can change the value of an item by using operator*() on the |
|
1301 |
left side of an assignment, for example: |
|
1302 |
||
1303 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 18 |
|
1304 |
||
1305 |
\sa operator->() |
|
1306 |
*/ |
|
1307 |
||
1308 |
/*! \fn T *QList::iterator::operator->() const |
|
1309 |
||
1310 |
Returns a pointer to the current item. |
|
1311 |
||
1312 |
\sa operator*() |
|
1313 |
*/ |
|
1314 |
||
1315 |
/*! \fn T &QList::iterator::operator[](int j) const |
|
1316 |
||
1317 |
Returns a modifiable reference to the item at position *this + |
|
1318 |
\a{j}. |
|
1319 |
||
1320 |
This function is provided to make QList iterators behave like C++ |
|
1321 |
pointers. |
|
1322 |
||
1323 |
\sa operator+() |
|
1324 |
*/ |
|
1325 |
||
1326 |
/*! |
|
1327 |
\fn bool QList::iterator::operator==(const iterator &other) const |
|
1328 |
\fn bool QList::iterator::operator==(const const_iterator &other) const |
|
1329 |
||
1330 |
Returns true if \a other points to the same item as this |
|
1331 |
iterator; otherwise returns false. |
|
1332 |
||
1333 |
\sa operator!=() |
|
1334 |
*/ |
|
1335 |
||
1336 |
/*! |
|
1337 |
\fn bool QList::iterator::operator!=(const iterator &other) const |
|
1338 |
\fn bool QList::iterator::operator!=(const const_iterator &other) const |
|
1339 |
||
1340 |
Returns true if \a other points to a different item than this |
|
1341 |
iterator; otherwise returns false. |
|
1342 |
||
1343 |
\sa operator==() |
|
1344 |
*/ |
|
1345 |
||
1346 |
/*! |
|
1347 |
\fn bool QList::iterator::operator<(const iterator& other) const |
|
1348 |
\fn bool QList::iterator::operator<(const const_iterator& other) const |
|
1349 |
||
1350 |
Returns true if the item pointed to by this iterator is less than |
|
1351 |
the item pointed to by the \a other iterator. |
|
1352 |
*/ |
|
1353 |
||
1354 |
/*! |
|
1355 |
\fn bool QList::iterator::operator<=(const iterator& other) const |
|
1356 |
\fn bool QList::iterator::operator<=(const const_iterator& other) const |
|
1357 |
||
1358 |
Returns true if the item pointed to by this iterator is less than |
|
1359 |
or equal to the item pointed to by the \a other iterator. |
|
1360 |
*/ |
|
1361 |
||
1362 |
/*! |
|
1363 |
\fn bool QList::iterator::operator>(const iterator& other) const |
|
1364 |
\fn bool QList::iterator::operator>(const const_iterator& other) const |
|
1365 |
||
1366 |
Returns true if the item pointed to by this iterator is greater |
|
1367 |
than the item pointed to by the \a other iterator. |
|
1368 |
*/ |
|
1369 |
||
1370 |
/*! |
|
1371 |
\fn bool QList::iterator::operator>=(const iterator& other) const |
|
1372 |
\fn bool QList::iterator::operator>=(const const_iterator& other) const |
|
1373 |
||
1374 |
Returns true if the item pointed to by this iterator is greater |
|
1375 |
than or equal to the item pointed to by the \a other iterator. |
|
1376 |
*/ |
|
1377 |
||
1378 |
/*! \fn QList::iterator &QList::iterator::operator++() |
|
1379 |
||
1380 |
The prefix ++ operator (\c{++it}) advances the iterator to the |
|
1381 |
next item in the list and returns an iterator to the new current |
|
1382 |
item. |
|
1383 |
||
1384 |
Calling this function on QList::end() leads to undefined results. |
|
1385 |
||
1386 |
\sa operator--() |
|
1387 |
*/ |
|
1388 |
||
1389 |
/*! \fn QList::iterator QList::iterator::operator++(int) |
|
1390 |
||
1391 |
\overload |
|
1392 |
||
1393 |
The postfix ++ operator (\c{it++}) advances the iterator to the |
|
1394 |
next item in the list and returns an iterator to the previously |
|
1395 |
current item. |
|
1396 |
*/ |
|
1397 |
||
1398 |
/*! \fn QList::iterator &QList::iterator::operator--() |
|
1399 |
||
1400 |
The prefix -- operator (\c{--it}) makes the preceding item |
|
1401 |
current and returns an iterator to the new current item. |
|
1402 |
||
1403 |
Calling this function on QList::begin() leads to undefined results. |
|
1404 |
||
1405 |
\sa operator++() |
|
1406 |
*/ |
|
1407 |
||
1408 |
/*! \fn QList::iterator QList::iterator::operator--(int) |
|
1409 |
||
1410 |
\overload |
|
1411 |
||
1412 |
The postfix -- operator (\c{it--}) makes the preceding item |
|
1413 |
current and returns an iterator to the previously current item. |
|
1414 |
*/ |
|
1415 |
||
1416 |
/*! \fn QList::iterator &QList::iterator::operator+=(int j) |
|
1417 |
||
1418 |
Advances the iterator by \a j items. (If \a j is negative, the |
|
1419 |
iterator goes backward.) |
|
1420 |
||
1421 |
\sa operator-=(), operator+() |
|
1422 |
*/ |
|
1423 |
||
1424 |
/*! \fn QList::iterator &QList::iterator::operator-=(int j) |
|
1425 |
||
1426 |
Makes the iterator go back by \a j items. (If \a j is negative, |
|
1427 |
the iterator goes forward.) |
|
1428 |
||
1429 |
\sa operator+=(), operator-() |
|
1430 |
*/ |
|
1431 |
||
1432 |
/*! \fn QList::iterator QList::iterator::operator+(int j) const |
|
1433 |
||
1434 |
Returns an iterator to the item at \a j positions forward from |
|
1435 |
this iterator. (If \a j is negative, the iterator goes backward.) |
|
1436 |
||
1437 |
\sa operator-(), operator+=() |
|
1438 |
*/ |
|
1439 |
||
1440 |
/*! \fn QList::iterator QList::iterator::operator-(int j) const |
|
1441 |
||
1442 |
Returns an iterator to the item at \a j positions backward from |
|
1443 |
this iterator. (If \a j is negative, the iterator goes forward.) |
|
1444 |
||
1445 |
\sa operator+(), operator-=() |
|
1446 |
*/ |
|
1447 |
||
1448 |
/*! \fn int QList::iterator::operator-(iterator other) const |
|
1449 |
||
1450 |
Returns the number of items between the item pointed to by \a |
|
1451 |
other and the item pointed to by this iterator. |
|
1452 |
*/ |
|
1453 |
||
1454 |
/*! \class QList::const_iterator |
|
1455 |
\brief The QList::const_iterator class provides an STL-style const iterator for QList and QQueue. |
|
1456 |
||
1457 |
QList provides both \l{STL-style iterators} and \l{Java-style |
|
1458 |
iterators}. The STL-style iterators are more low-level and more |
|
1459 |
cumbersome to use; on the other hand, they are slightly faster |
|
1460 |
and, for developers who already know STL, have the advantage of |
|
1461 |
familiarity. |
|
1462 |
||
1463 |
QList\<T\>::const_iterator allows you to iterate over a |
|
1464 |
QList\<T\> (or a QQueue\<T\>). If you want to modify the QList as |
|
1465 |
you iterate over it, use QList::iterator instead. It is generally |
|
1466 |
good practice to use QList::const_iterator on a non-const QList |
|
1467 |
as well, unless you need to change the QList through the |
|
1468 |
iterator. Const iterators are slightly faster, and can improve |
|
1469 |
code readability. |
|
1470 |
||
1471 |
The default QList::const_iterator constructor creates an |
|
1472 |
uninitialized iterator. You must initialize it using a QList |
|
1473 |
function like QList::constBegin(), QList::constEnd(), or |
|
1474 |
QList::insert() before you can start iterating. Here's a typical |
|
1475 |
loop that prints all the items stored in a list: |
|
1476 |
||
1477 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 19 |
|
1478 |
||
1479 |
Most QList functions accept an integer index rather than an |
|
1480 |
iterator. For that reason, iterators are rarely useful in |
|
1481 |
connection with QList. One place where STL-style iterators do |
|
1482 |
make sense is as arguments to \l{generic algorithms}. |
|
1483 |
||
1484 |
For example, here's how to delete all the widgets stored in a |
|
1485 |
QList\<QWidget *\>: |
|
1486 |
||
1487 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 20 |
|
1488 |
||
1489 |
Multiple iterators can be used on the same list. However, be |
|
1490 |
aware that any non-const function call performed on the QList |
|
1491 |
will render all existing iterators undefined. If you need to keep |
|
1492 |
iterators over a long period of time, we recommend that you use |
|
1493 |
QLinkedList rather than QList. |
|
1494 |
||
1495 |
\sa QList::iterator, QListIterator |
|
1496 |
*/ |
|
1497 |
||
1498 |
/*! \fn QList::const_iterator::const_iterator() |
|
1499 |
||
1500 |
Constructs an uninitialized iterator. |
|
1501 |
||
1502 |
Functions like operator*() and operator++() should not be called |
|
1503 |
on an uninitialized iterator. Use operator=() to assign a value |
|
1504 |
to it before using it. |
|
1505 |
||
1506 |
\sa QList::constBegin() QList::constEnd() |
|
1507 |
*/ |
|
1508 |
||
1509 |
/*! \typedef QList::const_iterator::iterator_category |
|
1510 |
||
1511 |
A synonym for \e {std::random_access_iterator_tag} indicating |
|
1512 |
this iterator is a random access iterator. |
|
1513 |
*/ |
|
1514 |
||
1515 |
/*! \typedef QList::const_iterator::difference_type |
|
1516 |
||
1517 |
\internal |
|
1518 |
*/ |
|
1519 |
||
1520 |
/*! \typedef QList::const_iterator::value_type |
|
1521 |
||
1522 |
\internal |
|
1523 |
*/ |
|
1524 |
||
1525 |
/*! \typedef QList::const_iterator::pointer |
|
1526 |
||
1527 |
\internal |
|
1528 |
*/ |
|
1529 |
||
1530 |
/*! \typedef QList::const_iterator::reference |
|
1531 |
||
1532 |
\internal |
|
1533 |
*/ |
|
1534 |
||
1535 |
/*! \fn QList::const_iterator::const_iterator(Node *node) |
|
1536 |
||
1537 |
\internal |
|
1538 |
*/ |
|
1539 |
||
1540 |
/*! \fn QList::const_iterator::const_iterator(const const_iterator &other) |
|
1541 |
||
1542 |
Constructs a copy of \a other. |
|
1543 |
*/ |
|
1544 |
||
1545 |
/*! \fn QList::const_iterator::const_iterator(const iterator &other) |
|
1546 |
||
1547 |
Constructs a copy of \a other. |
|
1548 |
*/ |
|
1549 |
||
1550 |
/*! \fn const T &QList::const_iterator::operator*() const |
|
1551 |
||
1552 |
Returns the current item. |
|
1553 |
||
1554 |
\sa operator->() |
|
1555 |
*/ |
|
1556 |
||
1557 |
/*! \fn const T *QList::const_iterator::operator->() const |
|
1558 |
||
1559 |
Returns a pointer to the current item. |
|
1560 |
||
1561 |
\sa operator*() |
|
1562 |
*/ |
|
1563 |
||
1564 |
/*! \fn const T &QList::const_iterator::operator[](int j) const |
|
1565 |
||
1566 |
Returns the item at position *this + \a{j}. |
|
1567 |
||
1568 |
This function is provided to make QList iterators behave like C++ |
|
1569 |
pointers. |
|
1570 |
||
1571 |
\sa operator+() |
|
1572 |
*/ |
|
1573 |
||
1574 |
/*! \fn bool QList::const_iterator::operator==(const const_iterator &other) const |
|
1575 |
||
1576 |
Returns true if \a other points to the same item as this |
|
1577 |
iterator; otherwise returns false. |
|
1578 |
||
1579 |
\sa operator!=() |
|
1580 |
*/ |
|
1581 |
||
1582 |
/*! \fn bool QList::const_iterator::operator!=(const const_iterator &other) const |
|
1583 |
||
1584 |
Returns true if \a other points to a different item than this |
|
1585 |
iterator; otherwise returns false. |
|
1586 |
||
1587 |
\sa operator==() |
|
1588 |
*/ |
|
1589 |
||
1590 |
/*! |
|
1591 |
\fn bool QList::const_iterator::operator<(const const_iterator& other) const |
|
1592 |
||
1593 |
Returns true if the item pointed to by this iterator is less than |
|
1594 |
the item pointed to by the \a other iterator. |
|
1595 |
*/ |
|
1596 |
||
1597 |
/*! |
|
1598 |
\fn bool QList::const_iterator::operator<=(const const_iterator& other) const |
|
1599 |
||
1600 |
Returns true if the item pointed to by this iterator is less than |
|
1601 |
or equal to the item pointed to by the \a other iterator. |
|
1602 |
*/ |
|
1603 |
||
1604 |
/*! |
|
1605 |
\fn bool QList::const_iterator::operator>(const const_iterator& other) const |
|
1606 |
||
1607 |
Returns true if the item pointed to by this iterator is greater |
|
1608 |
than the item pointed to by the \a other iterator. |
|
1609 |
*/ |
|
1610 |
||
1611 |
/*! |
|
1612 |
\fn bool QList::const_iterator::operator>=(const const_iterator& other) const |
|
1613 |
||
1614 |
Returns true if the item pointed to by this iterator is greater |
|
1615 |
than or equal to the item pointed to by the \a other iterator. |
|
1616 |
*/ |
|
1617 |
||
1618 |
/*! \fn QList::const_iterator &QList::const_iterator::operator++() |
|
1619 |
||
1620 |
The prefix ++ operator (\c{++it}) advances the iterator to the |
|
1621 |
next item in the list and returns an iterator to the new current |
|
1622 |
item. |
|
1623 |
||
1624 |
Calling this function on QList::end() leads to undefined results. |
|
1625 |
||
1626 |
\sa operator--() |
|
1627 |
*/ |
|
1628 |
||
1629 |
/*! \fn QList::const_iterator QList::const_iterator::operator++(int) |
|
1630 |
||
1631 |
\overload |
|
1632 |
||
1633 |
The postfix ++ operator (\c{it++}) advances the iterator to the |
|
1634 |
next item in the list and returns an iterator to the previously |
|
1635 |
current item. |
|
1636 |
*/ |
|
1637 |
||
1638 |
/*! \fn QList::const_iterator &QList::const_iterator::operator--() |
|
1639 |
||
1640 |
The prefix -- operator (\c{--it}) makes the preceding item |
|
1641 |
current and returns an iterator to the new current item. |
|
1642 |
||
1643 |
Calling this function on QList::begin() leads to undefined results. |
|
1644 |
||
1645 |
\sa operator++() |
|
1646 |
*/ |
|
1647 |
||
1648 |
/*! \fn QList::const_iterator QList::const_iterator::operator--(int) |
|
1649 |
||
1650 |
\overload |
|
1651 |
||
1652 |
The postfix -- operator (\c{it--}) makes the preceding item |
|
1653 |
current and returns an iterator to the previously current item. |
|
1654 |
*/ |
|
1655 |
||
1656 |
/*! \fn QList::const_iterator &QList::const_iterator::operator+=(int j) |
|
1657 |
||
1658 |
Advances the iterator by \a j items. (If \a j is negative, the |
|
1659 |
iterator goes backward.) |
|
1660 |
||
1661 |
\sa operator-=(), operator+() |
|
1662 |
*/ |
|
1663 |
||
1664 |
/*! \fn QList::const_iterator &QList::const_iterator::operator-=(int j) |
|
1665 |
||
1666 |
Makes the iterator go back by \a j items. (If \a j is negative, |
|
1667 |
the iterator goes forward.) |
|
1668 |
||
1669 |
\sa operator+=(), operator-() |
|
1670 |
*/ |
|
1671 |
||
1672 |
/*! \fn QList::const_iterator QList::const_iterator::operator+(int j) const |
|
1673 |
||
1674 |
Returns an iterator to the item at \a j positions forward from |
|
1675 |
this iterator. (If \a j is negative, the iterator goes backward.) |
|
1676 |
||
1677 |
\sa operator-(), operator+=() |
|
1678 |
*/ |
|
1679 |
||
1680 |
/*! \fn QList::const_iterator QList::const_iterator::operator-(int j) const |
|
1681 |
||
1682 |
Returns an iterator to the item at \a j positions backward from |
|
1683 |
this iterator. (If \a j is negative, the iterator goes forward.) |
|
1684 |
||
1685 |
\sa operator+(), operator-=() |
|
1686 |
*/ |
|
1687 |
||
1688 |
/*! \fn int QList::const_iterator::operator-(const_iterator other) const |
|
1689 |
||
1690 |
Returns the number of items between the item pointed to by \a |
|
1691 |
other and the item pointed to by this iterator. |
|
1692 |
*/ |
|
1693 |
||
1694 |
/*! \fn QDataStream &operator<<(QDataStream &out, const QList<T> &list) |
|
1695 |
\relates QList |
|
1696 |
||
1697 |
Writes the list \a list to stream \a out. |
|
1698 |
||
1699 |
This function requires the value type to implement \c |
|
1700 |
operator<<(). |
|
1701 |
||
1702 |
\sa \link datastreamformat.html Format of the QDataStream operators \endlink |
|
1703 |
*/ |
|
1704 |
||
1705 |
/*! \fn QDataStream &operator>>(QDataStream &in, QList<T> &list) |
|
1706 |
\relates QList |
|
1707 |
||
1708 |
Reads a list from stream \a in into \a list. |
|
1709 |
||
1710 |
This function requires the value type to implement \c |
|
1711 |
operator>>(). |
|
1712 |
||
1713 |
\sa \link datastreamformat.html Format of the QDataStream operators \endlink |
|
1714 |
*/ |
|
1715 |
||
1716 |
/*! |
|
1717 |
\fn iterator QList::remove(iterator pos) |
|
1718 |
||
1719 |
Use erase() instead. |
|
1720 |
*/ |
|
1721 |
||
1722 |
/*! |
|
1723 |
\fn int QList::remove(const T &t) |
|
1724 |
||
1725 |
Use removeAll() instead. |
|
1726 |
*/ |
|
1727 |
||
1728 |
/*! |
|
1729 |
\fn int QList::findIndex(const T& t) const |
|
1730 |
||
1731 |
Use indexOf() instead. |
|
1732 |
*/ |
|
1733 |
||
1734 |
/*! |
|
1735 |
\fn iterator QList::find(const T& t) |
|
1736 |
||
1737 |
Use indexOf() instead. |
|
1738 |
*/ |
|
1739 |
||
1740 |
/*! |
|
1741 |
\fn const_iterator QList::find (const T& t) const |
|
1742 |
||
1743 |
Use indexOf() instead. |
|
1744 |
*/ |
|
1745 |
||
1746 |
/*! |
|
1747 |
\fn iterator QList::find(iterator from, const T& t) |
|
1748 |
||
1749 |
Use indexOf() instead. |
|
1750 |
*/ |
|
1751 |
||
1752 |
/*! |
|
1753 |
\fn const_iterator QList::find(const_iterator from, const T& t) const |
|
1754 |
||
1755 |
Use indexOf() instead. |
|
1756 |
*/ |
|
1757 |
||
1758 |
/*! \fn QList<T> QList<T>::fromVector(const QVector<T> &vector) |
|
1759 |
||
1760 |
Returns a QList object with the data contained in \a vector. |
|
1761 |
||
1762 |
Example: |
|
1763 |
||
1764 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 21 |
|
1765 |
||
1766 |
\sa fromSet(), toVector(), QVector::toList() |
|
1767 |
*/ |
|
1768 |
||
1769 |
/*! \fn QVector<T> QList<T>::toVector() const |
|
1770 |
||
1771 |
Returns a QVector object with the data contained in this QList. |
|
1772 |
||
1773 |
Example: |
|
1774 |
||
1775 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 22 |
|
1776 |
||
1777 |
\sa toSet(), fromVector(), QVector::fromList() |
|
1778 |
*/ |
|
1779 |
||
1780 |
/*! \fn QList<T> QList<T>::fromSet(const QSet<T> &set) |
|
1781 |
||
1782 |
Returns a QList object with the data contained in \a set. The |
|
1783 |
order of the elements in the QList is undefined. |
|
1784 |
||
1785 |
Example: |
|
1786 |
||
1787 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 23 |
|
1788 |
||
1789 |
\sa fromVector(), toSet(), QSet::toList(), qSort() |
|
1790 |
*/ |
|
1791 |
||
1792 |
/*! \fn QSet<T> QList<T>::toSet() const |
|
1793 |
||
1794 |
Returns a QSet object with the data contained in this QList. |
|
1795 |
Since QSet doesn't allow duplicates, the resulting QSet might be |
|
1796 |
smaller than the original list was. |
|
1797 |
||
1798 |
Example: |
|
1799 |
||
1800 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 24 |
|
1801 |
||
1802 |
\sa toVector(), fromSet(), QSet::fromList() |
|
1803 |
*/ |
|
1804 |
||
1805 |
/*! \fn QList<T> QList<T>::fromStdList(const std::list<T> &list) |
|
1806 |
||
1807 |
Returns a QList object with the data contained in \a list. The |
|
1808 |
order of the elements in the QList is the same as in \a list. |
|
1809 |
||
1810 |
Example: |
|
1811 |
||
1812 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 25 |
|
1813 |
||
1814 |
\sa toStdList(), QVector::fromStdVector() |
|
1815 |
*/ |
|
1816 |
||
1817 |
/*! \fn std::list<T> QList<T>::toStdList() const |
|
1818 |
||
1819 |
Returns a std::list object with the data contained in this QList. |
|
1820 |
Example: |
|
1821 |
||
1822 |
\snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 26 |
|
1823 |
||
1824 |
\sa fromStdList(), QVector::toStdVector() |
|
1825 |
*/ |
|
1826 |
||
1827 |
QT_END_NAMESPACE |