Warning: That file was not part of the compilation database. It may have many parsing errors.
1 | /**************************************************************************** |
---|---|
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the documentation of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:FDL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Free Documentation License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Free |
19 | ** Documentation License version 1.3 as published by the Free Software |
20 | ** Foundation and appearing in the file included in the packaging of |
21 | ** this file. Please review the following information to ensure |
22 | ** the GNU Free Documentation License version 1.3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/fdl-1.3.html. |
24 | ** $QT_END_LICENSE$ |
25 | ** |
26 | ****************************************************************************/ |
27 | |
28 | /*! |
29 | \class QVarLengthArray |
30 | \inmodule QtCore |
31 | \brief The QVarLengthArray class provides a low-level variable-length array. |
32 | |
33 | \ingroup tools |
34 | \reentrant |
35 | |
36 | The C++ language doesn't support variable-length arrays on the stack. |
37 | For example, the following code won't compile: |
38 | |
39 | \snippet code/doc_src_qvarlengtharray.cpp 0 |
40 | |
41 | The alternative is to allocate the array on the heap (with |
42 | \c{new}): |
43 | |
44 | \snippet code/doc_src_qvarlengtharray.cpp 1 |
45 | |
46 | However, if myfunc() is called very frequently from the |
47 | application's inner loop, heap allocation can be a major source |
48 | of slowdown. |
49 | |
50 | QVarLengthArray is an attempt to work around this gap in the C++ |
51 | language. It allocates a certain number of elements on the stack, |
52 | and if you resize the array to a larger size, it automatically |
53 | uses the heap instead. Stack allocation has the advantage that |
54 | it is much faster than heap allocation. |
55 | |
56 | Example: |
57 | \snippet code/doc_src_qvarlengtharray.cpp 2 |
58 | |
59 | In the example above, QVarLengthArray will preallocate 1024 |
60 | elements on the stack and use them unless \c{n + 1} is greater |
61 | than 1024. If you omit the second template argument, |
62 | QVarLengthArray's default of 256 is used. |
63 | |
64 | QVarLengthArray's value type must be an \l{assignable data type}. |
65 | This covers most data types that are commonly used, but the |
66 | compiler won't let you, for example, store a QWidget as a value; |
67 | instead, store a QWidget *. |
68 | |
69 | QVarLengthArray, like QVector, provides a resizable array data |
70 | structure. The main differences between the two classes are: |
71 | |
72 | \list |
73 | \li QVarLengthArray's API is much more low-level and it lacks |
74 | some of QVector's functionality. |
75 | |
76 | \li QVarLengthArray doesn't initialize the memory if the value is |
77 | a basic type. (QVector always does.) |
78 | |
79 | \li QVector uses \l{implicit sharing} as a memory optimization. |
80 | QVarLengthArray doesn't provide that feature; however, it |
81 | usually produces slightly better performance due to reduced |
82 | overhead, especially in tight loops. |
83 | \endlist |
84 | |
85 | In summary, QVarLengthArray is a low-level optimization class |
86 | that only makes sense in very specific cases. It is used a few |
87 | places inside Qt and was added to Qt's public API for the |
88 | convenience of advanced users. |
89 | |
90 | \sa QVector, QList, QLinkedList |
91 | */ |
92 | |
93 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::QVarLengthArray(int size) |
94 | |
95 | Constructs an array with an initial size of \a size elements. |
96 | |
97 | If the value type is a primitive type (e.g., char, int, float) or |
98 | a pointer type (e.g., QWidget *), the elements are not |
99 | initialized. For other types, the elements are initialized with a |
100 | \l{default-constructed value}. |
101 | */ |
102 | |
103 | |
104 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::QVarLengthArray(std::initializer_list<T> args) |
105 | \since 5.5 |
106 | |
107 | Constructs an array from the std::initializer_list given by \a args. |
108 | |
109 | This constructor is only enabled if the compiler supports C++11 initializer |
110 | lists. |
111 | */ |
112 | |
113 | /*! \fn template<class T, int Prealloc> template<typename InputIterator> QVarLengthArray<T, Prealloc>::QVarLengthArray(InputIterator first, InputIterator last) |
114 | \since 5.14 |
115 | |
116 | Constructs an array with the contents in the iterator range [\a first, \a last). |
117 | |
118 | The value type of \c InputIterator must be convertible to \c T. |
119 | */ |
120 | |
121 | |
122 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::~QVarLengthArray() |
123 | |
124 | Destroys the array. |
125 | */ |
126 | |
127 | /*! \fn template<class T, int Prealloc> int QVarLengthArray<T, Prealloc>::size() const |
128 | |
129 | Returns the number of elements in the array. |
130 | |
131 | \sa isEmpty(), resize() |
132 | */ |
133 | |
134 | /*! \fn template<class T, int Prealloc> int QVarLengthArray<T, Prealloc>::count() const |
135 | |
136 | Same as size(). |
137 | |
138 | \sa isEmpty(), resize() |
139 | */ |
140 | |
141 | /*! \fn template<class T, int Prealloc> int QVarLengthArray<T, Prealloc>::length() const |
142 | \since 5.0 |
143 | |
144 | Same as size(). |
145 | |
146 | \sa isEmpty(), resize() |
147 | */ |
148 | |
149 | /*! \fn template<class T, int Prealloc> T& QVarLengthArray<T, Prealloc>::first() |
150 | |
151 | Returns a reference to the first item in the array. The array must |
152 | not be empty. If the array can be empty, check isEmpty() before |
153 | calling this function. |
154 | |
155 | \sa last(), isEmpty() |
156 | */ |
157 | |
158 | /*! \fn template<class T, int Prealloc> const T& QVarLengthArray<T, Prealloc>::first() const |
159 | |
160 | \overload |
161 | */ |
162 | |
163 | /*! \fn template<class T, int Prealloc> T& QVarLengthArray<T, Prealloc>::front() |
164 | \since 5.0 |
165 | |
166 | Same as first(). Provided for STL-compatibility. |
167 | */ |
168 | |
169 | /*! \fn template<class T, int Prealloc> const T& QVarLengthArray<T, Prealloc>::front() const |
170 | \since 5.0 |
171 | |
172 | \overload |
173 | */ |
174 | |
175 | /*! \fn template<class T, int Prealloc> T& QVarLengthArray<T, Prealloc>::last() |
176 | |
177 | Returns a reference to the last item in the array. The array must |
178 | not be empty. If the array can be empty, check isEmpty() before |
179 | calling this function. |
180 | |
181 | \sa first(), isEmpty() |
182 | */ |
183 | |
184 | /*! \fn template<class T, int Prealloc> const T& QVarLengthArray<T, Prealloc>::last() const |
185 | |
186 | \overload |
187 | */ |
188 | |
189 | /*! \fn template<class T, int Prealloc> T& QVarLengthArray<T, Prealloc>::back() |
190 | \since 5.0 |
191 | |
192 | Same as last(). Provided for STL-compatibility. |
193 | */ |
194 | |
195 | /*! \fn template<class T, int Prealloc> const T& QVarLengthArray<T, Prealloc>::back() const |
196 | \since 5.0 |
197 | |
198 | \overload |
199 | */ |
200 | |
201 | /*! \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::shrink_to_fit() |
202 | \since 5.10 |
203 | |
204 | Same as squeeze(). Provided for STL-compatibility. |
205 | */ |
206 | |
207 | /*! \fn template<class T, int Prealloc> bool QVarLengthArray<T, Prealloc>::isEmpty() const |
208 | |
209 | Returns \c true if the array has size 0; otherwise returns \c false. |
210 | |
211 | \sa size(), resize() |
212 | */ |
213 | |
214 | /*! \fn template<class T, int Prealloc> bool QVarLengthArray<T, Prealloc>::empty() const |
215 | \since 5.0 |
216 | |
217 | Returns \c true if the array has size 0; otherwise returns \c false. |
218 | |
219 | Same as isEmpty(). Provided for STL-compatibility. |
220 | */ |
221 | |
222 | /*! \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::clear() |
223 | |
224 | Removes all the elements from the array. |
225 | |
226 | Same as resize(0). |
227 | */ |
228 | |
229 | /*! \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::resize(int size) |
230 | |
231 | Sets the size of the array to \a size. If \a size is greater than |
232 | the current size, elements are added to the end. If \a size is |
233 | less than the current size, elements are removed from the end. |
234 | |
235 | If the value type is a primitive type (e.g., char, int, float) or |
236 | a pointer type (e.g., QWidget *), new elements are not |
237 | initialized. For other types, the elements are initialized with a |
238 | \l{default-constructed value}. |
239 | |
240 | \sa size(), squeeze() |
241 | */ |
242 | |
243 | /*! \fn template<class T, int Prealloc> int QVarLengthArray<T, Prealloc>::capacity() const |
244 | |
245 | Returns the maximum number of elements that can be stored in the |
246 | array without forcing a reallocation. |
247 | |
248 | The sole purpose of this function is to provide a means of fine |
249 | tuning QVarLengthArray's memory usage. In general, you will rarely ever |
250 | need to call this function. If you want to know how many items are |
251 | in the array, call size(). |
252 | |
253 | \sa reserve(), squeeze() |
254 | */ |
255 | |
256 | /*! \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::reserve(int size) |
257 | |
258 | Attempts to allocate memory for at least \a size elements. If you |
259 | know in advance how large the array can get, you can call this |
260 | function and if you call resize() often, you are likely to get |
261 | better performance. If \a size is an underestimate, the worst |
262 | that will happen is that the QVarLengthArray will be a bit |
263 | slower. |
264 | |
265 | The sole purpose of this function is to provide a means of fine |
266 | tuning QVarLengthArray's memory usage. In general, you will |
267 | rarely ever need to call this function. If you want to change the |
268 | size of the array, call resize(). |
269 | |
270 | \sa capacity(), squeeze() |
271 | */ |
272 | |
273 | /*! \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::squeeze() |
274 | \since 5.1 |
275 | |
276 | Releases any memory not required to store the items. |
277 | If the container can fit its storage on the stack allocation, |
278 | it will free the heap allocation and copy the elements back to the stack. |
279 | |
280 | The sole purpose of this function is to provide a means of fine |
281 | tuning QVarLengthArray's memory usage. In general, you will rarely ever |
282 | need to call this function. |
283 | |
284 | \sa reserve(), capacity(), resize() |
285 | */ |
286 | |
287 | /*! \fn template<class T, int Prealloc> T &QVarLengthArray<T, Prealloc>::operator[](int i) |
288 | |
289 | Returns a reference to the item at index position \a i. |
290 | |
291 | \a i must be a valid index position in the array (i.e., 0 <= \a i |
292 | < size()). |
293 | |
294 | \sa data(), at() |
295 | */ |
296 | |
297 | /*! \fn template<class T, int Prealloc> const T &QVarLengthArray<T, Prealloc>::operator[](int i) const |
298 | |
299 | \overload |
300 | */ |
301 | |
302 | |
303 | /*! |
304 | \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::append(const T &t) |
305 | |
306 | Appends item \a t to the array, extending the array if necessary. |
307 | |
308 | \sa removeLast() |
309 | */ |
310 | |
311 | /*! |
312 | \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::push_back(const T &t) |
313 | \since 5.0 |
314 | |
315 | Appends item \a t to the array, extending the array if necessary. |
316 | Provided for STL-compatibility. |
317 | */ |
318 | |
319 | /*! |
320 | \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::append(T &&t) |
321 | \overload append |
322 | \since 5.9 |
323 | |
324 | \note Unlike the lvalue overload of append(), passing a reference to |
325 | an object that is already an element of \c *this leads to undefined |
326 | behavior: |
327 | |
328 | \code |
329 | vla.append(std::move(vla[0])); // BUG: passing an object that is already in the container |
330 | \endcode |
331 | */ |
332 | |
333 | /*! |
334 | \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::push_back(T &&t) |
335 | \overload push_back |
336 | \since 5.9 |
337 | |
338 | \note Unlike the lvalue overload of push_back(), passing a reference to |
339 | an object that is already an element of \c *this leads to undefined |
340 | behavior: |
341 | |
342 | \code |
343 | vla.push_back(std::move(vla[0])); // BUG: passing an object that is already in the container |
344 | \endcode |
345 | */ |
346 | |
347 | /*! |
348 | \fn template<class T, int Prealloc> inline void QVarLengthArray<T, Prealloc>::removeLast() |
349 | \since 4.5 |
350 | |
351 | Decreases the size of the array by one. The allocated size is not changed. |
352 | |
353 | \sa append() |
354 | */ |
355 | |
356 | /*! |
357 | \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::pop_back() |
358 | \since 5.0 |
359 | |
360 | Same as removeLast(). Provided for STL-compatibility. |
361 | */ |
362 | |
363 | /*! |
364 | \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::append(const T *buf, int size) |
365 | |
366 | Appends \a size amount of items referenced by \a buf to this array. |
367 | */ |
368 | |
369 | |
370 | /*! \fn template<class T, int Prealloc> T *QVarLengthArray<T, Prealloc>::data() |
371 | |
372 | Returns a pointer to the data stored in the array. The pointer can |
373 | be used to access and modify the items in the array. |
374 | |
375 | Example: |
376 | \snippet code/doc_src_qvarlengtharray.cpp 3 |
377 | |
378 | The pointer remains valid as long as the array isn't reallocated. |
379 | |
380 | This function is mostly useful to pass an array to a function |
381 | that accepts a plain C++ array. |
382 | |
383 | \sa constData(), operator[]() |
384 | */ |
385 | |
386 | /*! \fn template<class T, int Prealloc> const T *QVarLengthArray<T, Prealloc>::data() const |
387 | |
388 | \overload |
389 | */ |
390 | |
391 | /*! \fn template<class T, int Prealloc> const T *QVarLengthArray<T, Prealloc>::constData() const |
392 | |
393 | Returns a const pointer to the data stored in the array. The |
394 | pointer can be used to access the items in the array. The |
395 | pointer remains valid as long as the array isn't reallocated. |
396 | |
397 | This function is mostly useful to pass an array to a function |
398 | that accepts a plain C++ array. |
399 | |
400 | \sa data(), operator[]() |
401 | */ |
402 | |
403 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc> &QVarLengthArray<T, Prealloc>::operator=(const QVarLengthArray<T, Prealloc> &other) |
404 | Assigns \a other to this array and returns a reference to this array. |
405 | */ |
406 | |
407 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc> &QVarLengthArray<T, Prealloc>::operator=(std::initializer_list<T> list) |
408 | \since 5.5 |
409 | |
410 | Assigns the values of \a list to this array, and returns a reference to this array. |
411 | |
412 | This constructor is only enabled if the compiler supports C++11 initializer |
413 | lists. |
414 | */ |
415 | |
416 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::QVarLengthArray(const QVarLengthArray<T, Prealloc> &other) |
417 | Constructs a copy of \a other. |
418 | */ |
419 | |
420 | /*! \fn template<class T, int Prealloc> const T &QVarLengthArray<T, Prealloc>::at(int i) const |
421 | |
422 | Returns a reference to the item at index position \a i. |
423 | |
424 | \a i must be a valid index position in the array (i.e., 0 <= \a i |
425 | < size()). |
426 | |
427 | \sa value(), operator[]() |
428 | */ |
429 | |
430 | /*! \fn template<class T, int Prealloc> T QVarLengthArray<T, Prealloc>::value(int i) const |
431 | |
432 | Returns the value at index position \a i. |
433 | |
434 | If the index \a i is out of bounds, the function returns |
435 | a \l{default-constructed value}. If you are certain that |
436 | \a i is within bounds, you can use at() instead, which is slightly |
437 | faster. |
438 | |
439 | \sa at(), operator[]() |
440 | */ |
441 | |
442 | /*! \fn template<class T, int Prealloc> T QVarLengthArray<T, Prealloc>::value(int i, const T &defaultValue) const |
443 | |
444 | \overload |
445 | |
446 | If the index \a i is out of bounds, the function returns |
447 | \a defaultValue. |
448 | */ |
449 | |
450 | /*! |
451 | \typedef QVarLengthArray::size_type |
452 | \since 4.7 |
453 | |
454 | Typedef for int. Provided for STL compatibility. |
455 | */ |
456 | |
457 | /*! |
458 | \typedef QVarLengthArray::value_type |
459 | \since 4.7 |
460 | |
461 | Typedef for T. Provided for STL compatibility. |
462 | */ |
463 | |
464 | /*! |
465 | \typedef QVarLengthArray::difference_type |
466 | \since 4.7 |
467 | |
468 | Typedef for ptrdiff_t. Provided for STL compatibility. |
469 | */ |
470 | |
471 | /*! |
472 | \typedef QVarLengthArray::pointer |
473 | \since 4.7 |
474 | |
475 | Typedef for T *. Provided for STL compatibility. |
476 | */ |
477 | |
478 | /*! |
479 | \typedef QVarLengthArray::const_pointer |
480 | \since 4.7 |
481 | |
482 | Typedef for const T *. Provided for STL compatibility. |
483 | */ |
484 | |
485 | /*! |
486 | \typedef QVarLengthArray::reference |
487 | \since 4.7 |
488 | |
489 | Typedef for T &. Provided for STL compatibility. |
490 | */ |
491 | |
492 | /*! |
493 | \typedef QVarLengthArray::const_reference |
494 | \since 4.7 |
495 | |
496 | Typedef for const T &. Provided for STL compatibility. |
497 | */ |
498 | |
499 | /*! |
500 | \typedef QVarLengthArray::const_iterator |
501 | \since 4.7 |
502 | |
503 | Typedef for const T *. Provided for STL compatibility. |
504 | */ |
505 | |
506 | /*! |
507 | \typedef QVarLengthArray::iterator |
508 | \since 4.7 |
509 | |
510 | Typedef for T *. Provided for STL compatibility. |
511 | */ |
512 | |
513 | /*! |
514 | \typedef QVarLengthArray::const_reverse_iterator |
515 | \since 5.6 |
516 | |
517 | Typedef for \c{std::reverse_iterator<const T*>}. Provided for STL compatibility. |
518 | */ |
519 | |
520 | /*! |
521 | \typedef QVarLengthArray::reverse_iterator |
522 | \since 5.6 |
523 | |
524 | Typedef for \c{std::reverse_iterator<T*>}. Provided for STL compatibility. |
525 | */ |
526 | |
527 | /*! |
528 | \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::prepend(const T &value) |
529 | \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::prepend(T &&value) |
530 | |
531 | \since 4.8 |
532 | Inserts \a value at the beginning of the array. |
533 | |
534 | |
535 | This is the same as vector.insert(0, \a value). |
536 | |
537 | For large arrays, this operation can be slow (\l{linear time}), |
538 | because it requires moving all the items in the vector by one |
539 | position further in memory. If you want a container class that |
540 | provides a fast prepend() function, use QList or QLinkedList |
541 | instead. |
542 | |
543 | \sa append(), insert() |
544 | */ |
545 | |
546 | /*! \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::replace(int i, const T &value) |
547 | |
548 | \since 4.8 |
549 | Replaces the item at index position \a i with \a value. |
550 | |
551 | \a i must be a valid index position in the array (i.e., 0 <= \a |
552 | i < size()). |
553 | |
554 | \sa operator[](), remove() |
555 | */ |
556 | |
557 | /*! \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::remove(int i) |
558 | |
559 | \overload |
560 | \since 4.8 |
561 | |
562 | Removes the element at index position \a i. |
563 | |
564 | \sa insert(), replace() |
565 | */ |
566 | |
567 | /*! \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::remove(int i, int count) |
568 | |
569 | \overload |
570 | \since 4.8 |
571 | |
572 | Removes \a count elements from the middle of the array, starting at |
573 | index position \a i. |
574 | |
575 | \sa insert(), replace() |
576 | */ |
577 | |
578 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::begin() |
579 | \since 4.8 |
580 | |
581 | Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in |
582 | the array. |
583 | |
584 | \sa constBegin(), end() |
585 | */ |
586 | |
587 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::const_iterator QVarLengthArray<T, Prealloc>::begin() const |
588 | \since 4.8 |
589 | \overload |
590 | */ |
591 | |
592 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::const_iterator QVarLengthArray<T, Prealloc>::cbegin() const |
593 | \since 5.0 |
594 | |
595 | Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item |
596 | in the array. |
597 | |
598 | \sa begin(), cend() |
599 | */ |
600 | |
601 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::const_iterator QVarLengthArray<T, Prealloc>::constBegin() const |
602 | \since 4.8 |
603 | |
604 | Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item |
605 | in the array. |
606 | |
607 | \sa begin(), constEnd() |
608 | */ |
609 | |
610 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::end() |
611 | \since 4.8 |
612 | |
613 | Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item |
614 | after the last item in the array. |
615 | |
616 | \sa begin(), constEnd() |
617 | */ |
618 | |
619 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::const_iterator QVarLengthArray<T, Prealloc>::end() const |
620 | \since 4.8 |
621 | |
622 | \overload |
623 | */ |
624 | |
625 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::const_iterator QVarLengthArray<T, Prealloc>::cend() const |
626 | \since 5.0 |
627 | |
628 | Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary |
629 | item after the last item in the array. |
630 | |
631 | \sa cbegin(), end() |
632 | */ |
633 | |
634 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::const_iterator QVarLengthArray<T, Prealloc>::constEnd() const |
635 | \since 4.8 |
636 | |
637 | Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary |
638 | item after the last item in the array. |
639 | |
640 | \sa constBegin(), end() |
641 | */ |
642 | |
643 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::reverse_iterator QVarLengthArray<T, Prealloc>::rbegin() |
644 | \since 5.6 |
645 | |
646 | Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to the first |
647 | item in the variable length array, in reverse order. |
648 | |
649 | \sa begin(), crbegin(), rend() |
650 | */ |
651 | |
652 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::const_reverse_iterator QVarLengthArray<T, Prealloc>::rbegin() const |
653 | \since 5.6 |
654 | \overload |
655 | */ |
656 | |
657 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::const_reverse_iterator QVarLengthArray<T, Prealloc>::crbegin() const |
658 | \since 5.6 |
659 | |
660 | Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to the first |
661 | item in the variable length array, in reverse order. |
662 | |
663 | \sa begin(), rbegin(), rend() |
664 | */ |
665 | |
666 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::reverse_iterator QVarLengthArray<T, Prealloc>::rend() |
667 | \since 5.6 |
668 | |
669 | Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to one past |
670 | the last item in the variable length array, in reverse order. |
671 | |
672 | \sa end(), crend(), rbegin() |
673 | */ |
674 | |
675 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::const_reverse_iterator QVarLengthArray<T, Prealloc>::rend() const |
676 | \since 5.6 |
677 | \overload |
678 | */ |
679 | |
680 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::const_reverse_iterator QVarLengthArray<T, Prealloc>::crend() const |
681 | \since 5.6 |
682 | |
683 | Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to one |
684 | past the last item in the variable length array, in reverse order. |
685 | |
686 | \sa end(), rend(), rbegin() |
687 | */ |
688 | |
689 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::erase(const_iterator pos) |
690 | \since 4.8 |
691 | |
692 | Removes the item pointed to by the iterator \a pos from the |
693 | vector, and returns an iterator to the next item in the vector |
694 | (which may be end()). |
695 | |
696 | \sa insert(), remove() |
697 | */ |
698 | |
699 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::erase(const_iterator begin, const_iterator end) |
700 | |
701 | \overload |
702 | \since 4.8 |
703 | |
704 | Removes all the items from \a begin up to (but not including) \a |
705 | end. Returns an iterator to the same item that \a end referred to |
706 | before the call. |
707 | */ |
708 | |
709 | /*! |
710 | \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::insert(int i, const T &value) |
711 | \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::insert(int i, T &&value) |
712 | \since 4.8 |
713 | |
714 | Inserts \a value at index position \a i in the array. If \a i is |
715 | 0, the value is prepended to the vector. If \a i is size(), the |
716 | value is appended to the vector. |
717 | |
718 | For large arrays, this operation can be slow (\l{linear time}), |
719 | because it requires moving all the items at indexes \a i and |
720 | above by one position further in memory. If you want a container |
721 | class that provides a fast insert() function, use QLinkedList |
722 | instead. |
723 | |
724 | \sa remove() |
725 | */ |
726 | |
727 | /*! \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::insert(int i, int count, const T &value) |
728 | |
729 | \overload |
730 | \since 4.8 |
731 | |
732 | Inserts \a count copies of \a value at index position \a i in the |
733 | vector. |
734 | */ |
735 | |
736 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::insert(const_iterator before, const T &value) |
737 | \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::insert(const_iterator before, T &&value) |
738 | |
739 | \overload |
740 | \since 4.8 |
741 | |
742 | Inserts \a value in front of the item pointed to by the iterator |
743 | \a before. Returns an iterator pointing at the inserted item. |
744 | */ |
745 | |
746 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::insert(const_iterator before, int count, const T &value) |
747 | |
748 | \since 4.8 |
749 | Inserts \a count copies of \a value in front of the item pointed to |
750 | by the iterator \a before. Returns an iterator pointing at the |
751 | first of the inserted items. |
752 | */ |
753 | |
754 | |
755 | |
756 | /*! \fn template<class T, int Prealloc1, int Prealloc2> bool operator==(const QVarLengthArray<T, Prealloc1> &left, const QVarLengthArray<T, Prealloc2> &right) |
757 | |
758 | \relates QVarLengthArray |
759 | \since 4.8 |
760 | Returns \c true if the two arrays, specified by \a left and \a right, are equal. |
761 | |
762 | Two arrays are considered equal if they contain the same values |
763 | in the same order. |
764 | |
765 | This function requires the value type to have an implementation |
766 | of \c operator==(). |
767 | |
768 | \sa operator!=() |
769 | */ |
770 | |
771 | /*! \fn template<typename T, int Prealloc1, int Prealloc2> bool operator!=(const QVarLengthArray<T, Prealloc1> &left, const QVarLengthArray<T, Prealloc2> &right) |
772 | |
773 | \relates QVarLengthArray |
774 | \since 4.8 |
775 | Returns \c true if the two arrays, specified by \a left and \a right, are \e not equal. |
776 | |
777 | Two arrays are considered equal if they contain the same values |
778 | in the same order. |
779 | |
780 | This function requires the value type to have an implementation |
781 | of \c operator==(). |
782 | |
783 | \sa operator==() |
784 | */ |
785 | |
786 | /*! \fn template<typename T, int Prealloc1, int Prealloc2> bool operator<(const QVarLengthArray<T,Prealloc1> &lhs, const QVarLengthArray<T,Prealloc2> &rhs) |
787 | \since 5.6 |
788 | \relates QVarLengthArray |
789 | |
790 | Returns \c true if variable length array \a lhs is |
791 | \l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare} |
792 | {lexicographically less than} \a rhs; otherwise returns \c false. |
793 | |
794 | This function requires the value type to have an implementation |
795 | of \c operator<(). |
796 | */ |
797 | |
798 | /*! \fn template<typename T, int Prealloc1, int Prealloc2> bool operator<=(const QVarLengthArray<T,Prealloc1> &lhs, const QVarLengthArray<T,Prealloc2> &rhs) |
799 | \since 5.6 |
800 | \relates QVarLengthArray |
801 | |
802 | Returns \c true if variable length array \a lhs is |
803 | \l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare} |
804 | {lexicographically less than or equal to} \a rhs; otherwise returns \c false. |
805 | |
806 | This function requires the value type to have an implementation |
807 | of \c operator<(). |
808 | */ |
809 | |
810 | /*! \fn template<typename T, int Prealloc1, int Prealloc2> bool operator>(const QVarLengthArray<T,Prealloc1> &lhs, const QVarLengthArray<T,Prealloc2> &rhs) |
811 | \since 5.6 |
812 | \relates QVarLengthArray |
813 | |
814 | Returns \c true if variable length array \a lhs is |
815 | \l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare} |
816 | {lexicographically greater than} \a rhs; otherwise returns \c false. |
817 | |
818 | This function requires the value type to have an implementation |
819 | of \c operator<(). |
820 | */ |
821 | |
822 | /*! \fn template<typename T, int Prealloc1, int Prealloc2> bool operator>=(const QVarLengthArray<T,Prealloc1> &lhs, const QVarLengthArray<T,Prealloc2> &rhs) |
823 | \since 5.6 |
824 | \relates QVarLengthArray |
825 | |
826 | Returns \c true if variable length array \a lhs is |
827 | \l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare} |
828 | {lexicographically greater than or equal to} \a rhs; otherwise returns \c false. |
829 | |
830 | This function requires the value type to have an implementation |
831 | of \c operator<(). |
832 | */ |
833 | |
834 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc> &QVarLengthArray<T, Prealloc>::operator<<(const T &value) |
835 | |
836 | \since 4.8 |
837 | Appends \a value to the array and returns a reference to this |
838 | vector. |
839 | |
840 | \sa append(), operator+=() |
841 | */ |
842 | |
843 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc> &QVarLengthArray<T, Prealloc>::operator<<(T &&value) |
844 | \since 5.11 |
845 | |
846 | \overload |
847 | |
848 | \sa append(), operator+=() |
849 | */ |
850 | |
851 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc> &QVarLengthArray<T, Prealloc>::operator+=(const T &value) |
852 | |
853 | \since 4.8 |
854 | Appends \a value to the array and returns a reference to this vector. |
855 | |
856 | \sa append(), operator<<() |
857 | */ |
858 | |
859 | /*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc> &QVarLengthArray<T, Prealloc>::operator+=(T &&value) |
860 | \since 5.11 |
861 | |
862 | \overload |
863 | |
864 | \sa append(), operator<<() |
865 | */ |
866 | |
867 | /*! \fn template<class T, int Prealloc> int QVarLengthArray<T, Prealloc>::indexOf(const T &value, int from = 0) const |
868 | |
869 | \since 5.3 |
870 | Returns the index position of the first occurrence of \a value in |
871 | the array, searching forward from index position \a from. |
872 | Returns -1 if no item matched. |
873 | |
874 | This function requires the value type to have an implementation of |
875 | \c operator==(). |
876 | |
877 | \sa lastIndexOf(), contains() |
878 | */ |
879 | |
880 | /*! \fn template<class T, int Prealloc> int QVarLengthArray<T, Prealloc>::lastIndexOf(const T &value, int from = -1) const |
881 | |
882 | \since 5.3 |
883 | Returns the index position of the last occurrence of the value \a |
884 | value in the array, searching backward from index position \a |
885 | from. If \a from is -1 (the default), the search starts at the |
886 | last item. Returns -1 if no item matched. |
887 | |
888 | This function requires the value type to have an implementation of |
889 | \c operator==(). |
890 | |
891 | \sa indexOf(), contains() |
892 | */ |
893 | |
894 | /*! \fn template<class T, int Prealloc> bool QVarLengthArray<T, Prealloc>::contains(const T &value) const |
895 | |
896 | \since 5.3 |
897 | Returns \c true if the array contains an occurrence of \a value; |
898 | otherwise returns \c false. |
899 | |
900 | This function requires the value type to have an implementation of |
901 | \c operator==(). |
902 | |
903 | \sa indexOf(), lastIndexOf() |
904 | */ |
905 | |
906 | /*! |
907 | template <typename T, int Prealloc> uint qHash(const QVarLengthArray<T, Prealloc> &key, uint seed = 0) |
908 | \relates QVarLengthArray |
909 | \since 5.14 |
910 | |
911 | Returns the hash value for \a key, using \a seed to seed the |
912 | calculation. |
913 | */ |
914 |
Warning: That file was not part of the compilation database. It may have many parsing errors.