Warning: That file was not part of the compilation database. It may have many parsing errors.
1 | /**************************************************************************** |
---|---|
2 | ** |
3 | ** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). |
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 | /* !\internal |
29 | \class Qt3DCore::QCircularBuffer |
30 | \inmodule Qt3DCore |
31 | \brief A template class providing a dynamic circular array. |
32 | |
33 | \ingroup tools |
34 | \ingroup shared |
35 | |
36 | \reentrant |
37 | |
38 | QCircularBuffer\<T\> is one of Qt's generic \l{container classes}. It |
39 | stores its items in adjacent memory locations and provides fast |
40 | index-based access. |
41 | |
42 | QCircularBuffer\<T\> provides similar functionality as QVector\<T\> and QList\<T\>, |
43 | but behaves differently when adding items to a full QCircularBuffer. Whereas |
44 | QVector\<T\> and QList\<T\> will both grow to accommodate the new items, |
45 | QCircularBuffer\<T\> will overwrite the oldest items. This provides circular |
46 | behavior to the container, and also means that it can maintain a flat memory |
47 | profile. |
48 | |
49 | QCircularBuffer\<T\> also offers performance gains over the other container classes when |
50 | doing lots of appending or prepending to the buffer, such as in data logging |
51 | applications. This is because appending (or prepending) an item does not require any |
52 | extra memory to be allocated, unlike, for example, QVector\<T\> or QList\<T\>. |
53 | Appending and prepending items to a QCircularBuffer\<T\> is an O(1) operation. |
54 | |
55 | As with QVector\<T\>, items in QCircularBuffer\<T\> occupy adjacent positions in memory. |
56 | However, the items may not be located in order in a single array. At times, the internal |
57 | indices used to store the positions of the first and last items may wrap around as the |
58 | QCircularBuffer\<T\> is modified. If the index of the last item is greater than the |
59 | index of the first item, then the buffer is said to be non-linearized. |
60 | |
61 | Here's an example of a QCircularBuffer that stores integers and a QCircularBuffer |
62 | that stores QString values: |
63 | |
64 | \snippet code/src_core_qcircularbuffer.cpp 0 |
65 | |
66 | The above examples create QCircularBuffer objects with a capacity of 0. The capacity |
67 | is the number of items that can be stored in a QCircularBuffer. The size of a |
68 | QCircularBuffer object is the number of items that actually are stored in it. Here's |
69 | an example of creating a QCircularBuffer with a capacity for 200 elements and a size of 0: |
70 | |
71 | \snippet code/src_core_qcircularbuffer.cpp 1 |
72 | |
73 | By default the QCircularBuffer is empty. If you want to create a circular buffer with |
74 | unused capacity, pass a size argument to the constructor. |
75 | |
76 | \snippet code/src_core_qcircularbuffer.cpp 2 |
77 | |
78 | If you wish to fill a subset of the QCircularBuffer with a default value, then you |
79 | should also pass a size argument to the constructor. The following example creates |
80 | a QCircularBuffer with a capacity for 200 QString items, and initializes the first 50 |
81 | of them to the value "Qt": |
82 | |
83 | \snippet code/src_core_qcircularbuffer.cpp 3 |
84 | |
85 | You can also call fill() at any time to fill the QCircularBuffer with a value. |
86 | |
87 | QCircularBuffer uses 0-based indexes, just like C++ arrays. To access the |
88 | item at a particular index position, you can use \l{operator[]()}{operator[]}. On |
89 | non-const buffers, \l{operator[]()}{operator[]} returns a reference to the item |
90 | that can be used on the left side of an assignment: |
91 | |
92 | \snippet code/src_core_qcircularbuffer.cpp 4 |
93 | |
94 | For read-only access, an alternative syntax is to use at(): |
95 | |
96 | \snippet code/src_core_qcircularbuffer.cpp 5 |
97 | |
98 | at() can be faster than \l{operator[]()}{operator[]}, because it never causes |
99 | a \l{deep copy} to occur. |
100 | |
101 | Another way to access the data stored in a QCircularBuffer is to call data(), |
102 | or dataOne() and dataTwo() depending on if the buffer is linearized or not. |
103 | See the discussion in isLinearised() for more information. The data() function |
104 | returns an \l array_range object describing the array of items stored |
105 | in the QCircularBuffer. You can use the pointer in the array_range to |
106 | directly access and modify the elements stored in the circular buffer. The pointer is also |
107 | useful if you need to pass a QCircularBuffer to a function that accepts a plain |
108 | C++ array. |
109 | |
110 | If the circular buffer is non-linearized, the data() function will |
111 | linearize it before returning. This can be an expensive operation for large buffers. |
112 | To avoid this cost, QCircularBuffer also provides alternative methods called |
113 | dataOne() and dataTwo() that return pointers to the two contiguous arrays used |
114 | to represent the buffer. dataOne() returns a pointer to the earlier (or oldest) |
115 | items, and dataTwo() returns a pointer to the later (or newer) items. The dataOne() |
116 | and dataTwo() functions never cause the circular buffer to be linearized. |
117 | |
118 | If you wish to pass a C++ array to a function and that function is expensive to call, |
119 | then you may wish to use the data() method so that you only need to call your |
120 | expensive function once. If your function is cheap and you have a large circular |
121 | buffer (so that linearizing it is expensive), then you may wish to use dataOne() and |
122 | dataTwo() and call your function twice. |
123 | |
124 | Here is a simple example that shows the semantics of how QCircularBuffer operates: |
125 | |
126 | \snippet code/src_core_qcircularbuffer.cpp 6 |
127 | |
128 | Notice how appending items to a full buffer overwrites the earliest items. |
129 | |
130 | If you want to find all occurrences of a particular value in a |
131 | circular buffer, use indexOf() or lastIndexOf(). The former searches |
132 | forward starting from a given index position, the latter searches |
133 | backward. Both return the index of the matching item if they found |
134 | one; otherwise, they return -1. For example: |
135 | |
136 | \snippet code/src_core_qcircularbuffer.cpp 7 |
137 | |
138 | If you simply want to check whether a circular buffer contains a |
139 | particular value, use contains(). If you want to find out how |
140 | many times a particular value occurs in the circular buffer, use count(). |
141 | |
142 | QCircularBuffer provides these basic functions to add, move, and remove |
143 | items: insert(), replace(), remove(), prepend(), append(). The insert() and |
144 | remove() functions can be slow (\l{linear time}) for large circular buffers, |
145 | because they require moving many items in the circular buffer by one or more positions |
146 | in memory. The implementation does however take care to minimize the number of |
147 | items that need to be moved. In the extreme worst case for insert() and remove(), |
148 | half of the items will be moved in memory. QCircularBuffer also takes care |
149 | to move items around using the best method available for the type being stored. |
150 | If your type is movable, then it is best to tell Qt about this by using the |
151 | Q_DECLARE_TYPEINFO() macro. In such cases memory moves are performed using |
152 | memmove() rather than calling the copy constructor for each item. If you want |
153 | a container class that always provides fast insertion/removal in the middle, |
154 | use QList or QLinkedList instead. |
155 | |
156 | Unlike plain C++ arrays, QCircularBuffers can be resized at any time by |
157 | calling resize() or setCapacity(). The resize() function can only allocate |
158 | items up to the number specified by capacity(). If you wish to alter the |
159 | capacity of the CircularBuffer, then use setCapacity(). This can be slow as |
160 | new memory needs to be allocated. It is most common to specify the capacity |
161 | of the circular buffer in the constructor or immediately after construction, |
162 | and then simply keep appending to the buffer. If you wish to reclaim any |
163 | unused memory from the circular buffer, then call squeeze(). This is |
164 | equivalent to calling \l {setCapacity()}{setCapacity}( size() ). |
165 | |
166 | Note that using non-const operators and functions can cause |
167 | QCircularBuffer to do a deep copy of the data. This is due to |
168 | \l{implicit sharing}. |
169 | |
170 | QCircularBuffer's value type must be an \l{assignable data type}. This |
171 | covers most data types that are commonly used, but the compiler |
172 | won't let you, for example, store a QWidget as a value; instead, |
173 | store a QWidget *. Some functions have additional requirements; |
174 | for example, indexOf() and lastIndexOf() expect the value type to |
175 | support \c operator==(). These requirements are documented on a |
176 | per-function basis. |
177 | |
178 | QCircularBuffer provides \l{STL-Style Iterators} (\l {const_iterator} |
179 | and \l {iterator}). In practice, these are rarely used, |
180 | because you can use indexes into the buffer. |
181 | |
182 | QCircularBuffer does \e not support inserting, prepending, appending, or |
183 | replacing with references to its own values. Doing so will cause your |
184 | application to abort with an error message. |
185 | |
186 | \sa iterator, const_iterator, QVector, QList, QLinkedList |
187 | */ |
188 | |
189 | /* \fn Qt3DCore::QCircularBuffer::QCircularBuffer() |
190 | |
191 | Constructs an empty circular buffer with zero capacity. |
192 | |
193 | \sa resize(), setCapacity() |
194 | */ |
195 | |
196 | /* \fn Qt3DCore::QCircularBuffer::QCircularBuffer(int capacity) |
197 | |
198 | Constructs an empty circular buffer with an initial capacity of \a capacity |
199 | elements. |
200 | |
201 | \sa resize(), setCapacity() |
202 | */ |
203 | |
204 | /* \fn Qt3DCore::QCircularBuffer::QCircularBuffer(int capacity, const T &value) |
205 | |
206 | Constructs a circular buffer with an initial capacity and size of |
207 | \a capacity elements. |
208 | |
209 | The elements are initialized to \a value. |
210 | |
211 | \sa resize(), setCapacity(), fill() |
212 | */ |
213 | |
214 | /* \fn Qt3DCore::QCircularBuffer::QCircularBuffer(int capacity, int size, const T &value) |
215 | |
216 | Constructs a circular buffer with an initial capacity of \a capacity |
217 | elements and initial size of \a size elements. |
218 | |
219 | The first \a size elements are initialized to \a value. |
220 | |
221 | \sa resize(), setCapacity(), fill() |
222 | */ |
223 | |
224 | /* \fn Qt3DCore::QCircularBuffer::QCircularBuffer(const QCircularBuffer<T> &other) |
225 | |
226 | Constructs a copy of \a other. |
227 | |
228 | This operation takes \l{constant time}, because QCircularBuffer is |
229 | \l{implicitly shared}. This makes returning a QCircularBuffer from a |
230 | function very fast. If a shared instance is modified, it will be |
231 | copied (copy-on-write), and that takes \l{linear time}. |
232 | |
233 | \sa operator=() |
234 | */ |
235 | |
236 | /* \fn Qt3DCore::QCircularBuffer::~QCircularBuffer() |
237 | |
238 | Destroys the circular buffer. |
239 | */ |
240 | |
241 | /* \fn QCircularBuffer &Qt3DCore::QCircularBuffer::operator=(const QCircularBuffer<T> &other) |
242 | |
243 | Assigns \a other to this circular buffer and returns a reference to this |
244 | circular buffer. |
245 | */ |
246 | |
247 | /* \fn Qt3DCore::QCircularBuffer::iterator Qt3DCore::QCircularBuffer::begin() |
248 | |
249 | Returns an \l{STL-Style iterators}{STL-style iterator} pointing to the first item in |
250 | the circular buffer. |
251 | |
252 | \sa constBegin(), end() |
253 | */ |
254 | |
255 | /* \fn Qt3DCore::QCircularBuffer::const_iterator Qt3DCore::QCircularBuffer::begin() const |
256 | |
257 | \overload |
258 | */ |
259 | |
260 | /* \fn Qt3DCore::QCircularBuffer::const_iterator Qt3DCore::QCircularBuffer::constBegin() const |
261 | |
262 | Returns a const \l{STL-Style Iterators}{STL-style iterator} pointing to the first item in |
263 | the circular buffer. |
264 | |
265 | \sa begin(), constEnd() |
266 | */ |
267 | |
268 | /* \fn Qt3DCore::QCircularBuffer::iterator Qt3DCore::QCircularBuffer::end() |
269 | |
270 | Returns an \l {STL-Style Iterators} {STL-style iterator} pointing to the imaginary item |
271 | after the last item in the circular buffer. |
272 | |
273 | \sa begin(), constEnd() |
274 | */ |
275 | |
276 | /* \fn Qt3DCore::QCircularBuffer::const_iterator Qt3DCore::QCircularBuffer::end() const |
277 | |
278 | \overload |
279 | */ |
280 | |
281 | /* \fn Qt3DCore::QCircularBuffer::const_iterator Qt3DCore::QCircularBuffer::constEnd() const |
282 | |
283 | Returns a const \l{STL-Style Iterators} {STL-style iterator} pointing to the imaginary item |
284 | after the last item in the circular buffer. |
285 | |
286 | \sa constBegin(), end() |
287 | */ |
288 | |
289 | /* \fn Qt3DCore::QCircularBuffer::iterator Qt3DCore::QCircularBuffer::erase(const_iterator pos) |
290 | |
291 | Removes the item pointed to by the iterator \a pos from the |
292 | circular buffer, and returns an iterator to the next item in the circular |
293 | buffer (which may be end()). |
294 | |
295 | \sa insert(), remove() |
296 | */ |
297 | |
298 | /* \fn Qt3DCore::QCircularBuffer::iterator Qt3DCore::QCircularBuffer::erase(const_iterator begin, const_iterator end) |
299 | |
300 | \overload |
301 | |
302 | Removes all the items from \a begin up to (but not including) \a |
303 | end. Returns an iterator to the same item that \a end referred to |
304 | before the call. |
305 | */ |
306 | |
307 | /* \fn void Qt3DCore::QCircularBuffer::push_back(const T &value) |
308 | |
309 | This function is provided for STL compatibility. It is equivalent |
310 | to append(\a value). |
311 | */ |
312 | |
313 | /* \fn void Qt3DCore::QCircularBuffer::push_front(const T &value) |
314 | |
315 | This function is provided for STL compatibility. It is equivalent |
316 | to prepend(\a value). |
317 | */ |
318 | |
319 | /* \fn void Qt3DCore::QCircularBuffer::pop_back() |
320 | |
321 | This function is provided for STL compatibility. It is equivalent |
322 | to erase(end() - 1). |
323 | */ |
324 | |
325 | /* \fn void Qt3DCore::QCircularBuffer::pop_front() |
326 | |
327 | This function is provided for STL compatibility. It is equivalent |
328 | to erase(begin()). |
329 | */ |
330 | |
331 | /* \fn bool Qt3DCore::QCircularBuffer::empty() const |
332 | |
333 | This function is provided for STL compatibility. It is equivalent |
334 | to isEmpty(), returning true if the circular buffer is empty; otherwise |
335 | returns false. |
336 | */ |
337 | |
338 | /* \fn Qt3DCore::QCircularBuffer::reference Qt3DCore::QCircularBuffer::front() |
339 | |
340 | This function is provided for STL compatibility. It is equivalent |
341 | to first(). |
342 | */ |
343 | |
344 | /* \fn Qt3DCore::QCircularBuffer::const_reference Qt3DCore::QCircularBuffer::front() const |
345 | |
346 | \overload |
347 | */ |
348 | |
349 | /* \fn Qt3DCore::QCircularBuffer::reference Qt3DCore::QCircularBuffer::back() |
350 | |
351 | This function is provided for STL compatibility. It is equivalent |
352 | to last(). |
353 | */ |
354 | |
355 | /* \fn Qt3DCore::QCircularBuffer::const_reference Qt3DCore::QCircularBuffer::back() const |
356 | |
357 | \overload |
358 | */ |
359 | |
360 | /* \fn int Qt3DCore::QCircularBuffer::refCount() const |
361 | |
362 | Returns the number of shallow copies that exist of this circular buffer. |
363 | */ |
364 | |
365 | /* \fn Qt3DCore::QCircularBuffer::append(const T &value) |
366 | |
367 | Inserts \a value at the end of the circular buffer. If the circular buffer |
368 | is full, then the oldest element is overwritten. |
369 | |
370 | Example: |
371 | \snippet code/src_core_qcircularbuffer.cpp 8 |
372 | |
373 | This operation is very fast, because QCircularBuffer never allocates |
374 | memory in this function. |
375 | |
376 | \sa operator<<(), operator+=(), prepend(), insert() |
377 | */ |
378 | |
379 | /* \fn const T &Qt3DCore::QCircularBuffer::at(int i) const |
380 | |
381 | Returns the item at index position \a i in the circular buffer. |
382 | |
383 | \a i must be a valid index position in the circular buffer |
384 | (i.e., 0 <= \a i < size()). |
385 | |
386 | \sa value(), operator[]() |
387 | */ |
388 | |
389 | /* \fn T &Qt3DCore::QCircularBuffer::operator[](int i) |
390 | |
391 | Returns the item at index position \a i as a modifiable reference. |
392 | |
393 | \a i must be a valid index position in the circular buffer (i.e., 0 <= \a i |
394 | < size()). |
395 | |
396 | Note that using non-const operators can cause QCircularBuffer to do a deep |
397 | copy. |
398 | |
399 | \sa at(), value() |
400 | */ |
401 | |
402 | /* \fn const T &Qt3DCore::QCircularBuffer::operator[](int i) const |
403 | |
404 | \overload |
405 | |
406 | Same as at(\a i). |
407 | */ |
408 | |
409 | /* \fn int Qt3DCore::QCircularBuffer::capacity() const |
410 | |
411 | Returns the maximum number of elements that can be stored in |
412 | the circular buffer. |
413 | |
414 | \sa setCapacity(), size() |
415 | */ |
416 | |
417 | /* \fn void Qt3DCore::QCircularBuffer::clear() |
418 | |
419 | Removes all elements from the circular buffer so that the size is |
420 | zero. The capacity is unchanged. |
421 | |
422 | \sa isEmpty() |
423 | */ |
424 | |
425 | /* \fn bool Qt3DCore::QCircularBuffer::contains(const T &value) const |
426 | |
427 | Returns true if the circular buffer contains an occurrence of \a value; |
428 | otherwise returns false. |
429 | |
430 | This function requires the value type to have an implementation of |
431 | \c operator==(). |
432 | |
433 | \sa indexOf(), count() |
434 | */ |
435 | |
436 | /* \fn int Qt3DCore::QCircularBuffer::count(const T &value) const |
437 | |
438 | Returns the number of occurrences of \a value in the circular buffer. |
439 | |
440 | This function requires the value type to have an implementation of |
441 | \c operator==(). |
442 | |
443 | \sa contains(), indexOf() |
444 | */ |
445 | |
446 | /* \fn int Qt3DCore::QCircularBuffer::count() const |
447 | |
448 | \overload |
449 | |
450 | Same as size(). |
451 | */ |
452 | |
453 | /* \fn Qt3DCore::QCircularBuffer::array_range Qt3DCore::QCircularBuffer::data() |
454 | |
455 | Returns an \l array_range describing the internal array of data. If |
456 | the circular buffer is non-linearized, then this function causes it to be |
457 | linearized. If the cost of linearisation is too high for your use case, then |
458 | you should consider using the dataOne() and dataTwo() functions instead. |
459 | |
460 | If the circular buffer is empty then the pointer and array size returned |
461 | will both be 0. |
462 | |
463 | \sa constData(), dataOne(), dataTwo(), isLinearised() |
464 | */ |
465 | |
466 | /* \fn Qt3DCore::QCircularBuffer::const_array_range Qt3DCore::QCircularBuffer::data() const |
467 | |
468 | \overload |
469 | |
470 | If the circular buffer is non-linearized then the pointer and array size |
471 | returned will both be 0 since linearising the circular buffer would break |
472 | constness. |
473 | */ |
474 | |
475 | /* \fn Qt3DCore::QCircularBuffer::const_array_range Qt3DCore::QCircularBuffer::constData() const |
476 | |
477 | Returns a \l const_array_range describing the internal array of |
478 | data. |
479 | |
480 | If the circular buffer is non-linearized then the pointer and array size |
481 | returned will both be 0 since linearising the circular buffer would break |
482 | constness. |
483 | |
484 | If the circular buffer is empty then the pointer and array size returned |
485 | will both be 0. |
486 | |
487 | \sa data(), constDataOne(), constDataTwo(), isLinearised() |
488 | */ |
489 | |
490 | /* \fn Qt3DCore::QCircularBuffer::array_range Qt3DCore::QCircularBuffer::dataOne() |
491 | |
492 | Returns an \l array_range describing the first internal array of |
493 | contiguous data. If the circular buffer is linearized, then this function is |
494 | equivalent to calling data(). If the circular buffer is non-linearized then |
495 | the returned array range will describe a subset of the data contained in the |
496 | circular buffer. This subset will consist of the earliest (lowest index) items |
497 | in the buffer. To obtain an \l array_range for the remainder of the data, use |
498 | the dataTwo() function. |
499 | |
500 | If the circular buffer is empty, then the pointer and array size returned |
501 | will both be 0. |
502 | |
503 | \sa constDataOne(), dataTwo(), data(), isLinearised() |
504 | */ |
505 | |
506 | /* \fn Qt3DCore::QCircularBuffer::const_array_range Qt3DCore::QCircularBuffer::dataOne() const |
507 | |
508 | \overload |
509 | |
510 | Unlike data(), this function always returns a valid \l const_array_range |
511 | (unless the circular buffer is empty). |
512 | */ |
513 | |
514 | /* \fn Qt3DCore::QCircularBuffer::const_array_range Qt3DCore::QCircularBuffer::constDataOne() const |
515 | |
516 | Returns a \l const_array_range describing the first internal array of |
517 | contiguous data. If the circular buffer is linearized, then this function is |
518 | equivalent to calling constData(). If the circular buffer is non-linearized, then |
519 | the returned array range will describe a subset of the data contained in the |
520 | circular buffer. This subset will consist of the earliest (lowest index) items |
521 | in the buffer. To obtain a \l const_array_range for the remainder of the data, |
522 | use the constDataTwo() function. |
523 | |
524 | If the circular buffer is empty, then the pointer and array size returned |
525 | will both be 0. |
526 | |
527 | \sa dataOne(), constDataTwo(), constData(), isLinearised() |
528 | */ |
529 | |
530 | /* \fn Qt3DCore::QCircularBuffer::array_range Qt3DCore::QCircularBuffer::dataTwo() |
531 | |
532 | Returns an \l array_range describing the first internal array of |
533 | contiguous data. If the circular buffer is linearized, then the pointer and array size |
534 | returned will both be 0 since all the data will be contained in the array |
535 | described by calling the dataOne() function. |
536 | |
537 | \sa dataOne(), constDataTwo(), data(), isLinearised() |
538 | */ |
539 | |
540 | /* \fn Qt3DCore::QCircularBuffer::const_array_range Qt3DCore::QCircularBuffer::dataTwo() const |
541 | |
542 | \overload |
543 | */ |
544 | |
545 | /* \fn Qt3DCore::QCircularBuffer::const_array_range Qt3DCore::QCircularBuffer::constDataTwo() const |
546 | |
547 | Returns a \l const_array_range describing the first internal array of |
548 | contiguous data. If the circular buffer is linearized, then the pointer and array size |
549 | returned will both be 0 since all the data will be contained in the array |
550 | described by calling the dataOne() function. |
551 | |
552 | \sa constDataOne(), dataTwo(), constData(), isLinearised() |
553 | */ |
554 | |
555 | /* \fn bool Qt3DCore::QCircularBuffer::endsWith(const T &value) const |
556 | |
557 | Returns \c true if this circular buffer is not empty and its last |
558 | item is equal to \a value; otherwise returns \c false. |
559 | |
560 | \sa isEmpty(), last(), startsWith() |
561 | */ |
562 | |
563 | /* \fn QCircularBuffer<T>& Qt3DCore::QCircularBuffer::fill(const T &value, int size = -1) |
564 | |
565 | Assigns \a value to all items in the circular buffer. If \a size is |
566 | different from -1 (the default), the circular buffer is resized to size \a |
567 | size beforehand (size must be less than or equal to the capacity). |
568 | |
569 | This function also linearizes the circular buffer. |
570 | |
571 | Example: |
572 | \snippet code/src_core_qcircularbuffer.cpp 14 |
573 | |
574 | \sa resize() |
575 | */ |
576 | |
577 | /* \fn T &Qt3DCore::QCircularBuffer::first() |
578 | |
579 | Returns a reference to the first item in the circular buffer. This |
580 | function assumes that the circular buffer isn't empty. |
581 | |
582 | \sa last(), isEmpty() |
583 | */ |
584 | |
585 | /* \fn const T &Qt3DCore::QCircularBuffer::first() const |
586 | |
587 | \overload |
588 | */ |
589 | |
590 | /* \fn int Qt3DCore::QCircularBuffer::freeSize() const |
591 | |
592 | Returns the number of items that can be added to the circular buffer |
593 | without causing the earliest item to be overwritten. It is equivalent |
594 | to (capacity() - size()). |
595 | |
596 | \sa sizeAvailable(), capacity(), isEmpty(), isFull(), size() |
597 | */ |
598 | |
599 | /* \fn static QCircularBuffer<T> Qt3DCore::QCircularBuffer::fromList(const QList<T>& list) |
600 | |
601 | Returns a QCircularBuffer object with the data contained in \a list. The |
602 | capacity and size of the circular buffer will be equal to the size of |
603 | \a list. |
604 | |
605 | Example: |
606 | \snippet code/src_core_qcircularbuffer.cpp 18 |
607 | |
608 | \sa fromVector(), toList(), toVector() |
609 | */ |
610 | |
611 | /* \fn static QCircularBuffer<T> Qt3DCore::QCircularBuffer::fromVector(const QVector<T>& vector) |
612 | |
613 | Returns a QCircularBuffer object with the data contained in \a vector. The |
614 | capacity and size of the circular buffer will be equal to the size of |
615 | \a vector. |
616 | |
617 | \sa fromList(), toVector(), toList() |
618 | */ |
619 | |
620 | /* \fn int Qt3DCore::QCircularBuffer::indexOf(const T &value, int from = 0) const |
621 | |
622 | Returns the index position of the first occurrence of \a value in |
623 | the circular buffer, searching forward from index position \a from. |
624 | Returns -1 if no item matched. |
625 | |
626 | Example: |
627 | \snippet code/src_core_qcircularbuffer.cpp 15 |
628 | |
629 | This function requires the value type to have an implementation of |
630 | \c operator==(). |
631 | |
632 | \sa lastIndexOf(), contains() |
633 | */ |
634 | |
635 | /* \fn void Qt3DCore::QCircularBuffer::insert(int i, const T &value) |
636 | |
637 | Inserts \a value at index position \a i in the circular buffer. |
638 | If \a i is 0, the value is prepended to the circular buffer. If \a i |
639 | is size(), the value is appended to the circular buffer. The capacity |
640 | of the circular buffer is not changed. |
641 | |
642 | Example: |
643 | \snippet code/src_core_qcircularbuffer.cpp 11 |
644 | |
645 | Using this function is equivalent to calling insert(i, 1, value). See the |
646 | discussion there for more information. |
647 | |
648 | Items at indexes \a i and higher are shifted along by one. If the circular |
649 | buffer is full then the earliest item will be overwritten. Note that this |
650 | has the non-obvious behavior that calling \c {insert(0, value)} on a circular |
651 | buffer that is already full will effectively do nothing since the newly |
652 | prepended item will immediately be overwritten by the highest item as it |
653 | is shifted along one position. |
654 | |
655 | For large circular buffers, this operation can be slow (\l{linear time}), |
656 | because it requires moving all the items at indexes \a i and |
657 | above (or all items below index i depending upon where in the circular buffer |
658 | the new item is inserted) by one position in memory. If you |
659 | want a container class that provides a fast insert() function, use |
660 | QLinkedList instead. |
661 | |
662 | If the capacity() is zero, then nothing will be inserted. |
663 | |
664 | \sa append(), prepend(), remove() |
665 | */ |
666 | |
667 | /* \fn void Qt3DCore::QCircularBuffer::insert(int i, int count, const T &value) |
668 | |
669 | \overload |
670 | |
671 | Inserts \a value at index position \a i in the circular buffer. |
672 | If \a i is 0, the value is prepended to the circular buffer. If \a i |
673 | is size(), the value is appended to the circular buffer. The capacity |
674 | of the circular buffer is not changed. |
675 | |
676 | Items at indexes \a i and higher are shifted along by one. If the circular |
677 | buffer has freeSize() < \a count, then the earliest items will be overwritten. |
678 | |
679 | The actual number of items that get inserted may not always be equal to |
680 | \a count since this function preserves the capacity of the circular buffer, |
681 | and since items at indexes i and higher are shifted along by one. |
682 | The actual number of items inserted is min(\a count, \a i + freeSize()). |
683 | |
684 | For the same reasons, the number of items that get overwritten at the |
685 | start of the circular buffer is min(\a i, max(0, \a count - freeSize())). |
686 | |
687 | Example: |
688 | \snippet code/src_core_qcircularbuffer.cpp 12 |
689 | |
690 | For large circular buffers, this operation can be slow (\l{linear time}), |
691 | because it requires moving all the items at indexes \a i and |
692 | above (or all items below index i depending upon where in the circular buffer |
693 | the new item is inserted) in memory. If you want a container class that |
694 | provides a fast insert() function, use QLinkedList instead. |
695 | |
696 | If the capacity() is zero, then nothing will be inserted. |
697 | |
698 | \sa append(), prepend(), remove() |
699 | */ |
700 | |
701 | /* \fn Qt3DCore::QCircularBuffer::iterator Qt3DCore::QCircularBuffer::insert(const_iterator before, int count, const T &value) |
702 | |
703 | \overload |
704 | |
705 | Inserts up to \a count items with value \a value in front of the item |
706 | pointed to by the iterator \a before in the circular buffer. Returns an |
707 | iterator pointing at the first of the inserted items. |
708 | |
709 | \sa append(), prepend(), remove() |
710 | */ |
711 | |
712 | /* \fn Qt3DCore::QCircularBuffer::iterator Qt3DCore::QCircularBuffer::insert(const_iterator before, const T &value) |
713 | |
714 | \overload |
715 | |
716 | Inserts \a value in front of the item pointed to by the iterator \a before. |
717 | Returns an iterator pointing at the inserted item. |
718 | |
719 | \sa append(), prepend(), remove() |
720 | */ |
721 | |
722 | /* \fn bool Qt3DCore::QCircularBuffer::isEmpty() const |
723 | |
724 | Returns true if the circular buffer has size 0; otherwise returns false. |
725 | |
726 | \sa capacity(), resize(), setCapacity(), size() |
727 | */ |
728 | |
729 | /* \fn bool Qt3DCore::QCircularBuffer::isFull() const |
730 | |
731 | Returns true if the circular buffer is full ie if size() == capacity(); otherwise returns false. |
732 | |
733 | \sa capacity(), resize(), setCapacity(), size() |
734 | */ |
735 | |
736 | /* \fn bool Qt3DCore::QCircularBuffer::isLinearised() const |
737 | |
738 | Returns \c true if the circular buffer is linearized; otherwise returns |
739 | \c false. |
740 | |
741 | A circular buffer is said to be linearized if the position of the first |
742 | item in the internal array occurs before the position of the last item. A |
743 | little more explanation is provided for clarification. |
744 | |
745 | Internally, QCircularBuffer stores the items in a plain C++ array. |
746 | Additionally, the positions in the array of the first and last items of |
747 | the circular buffer are also stored (along with the capacity and size). |
748 | |
749 | Imagine a circular buffer of capacity 6 created and populated with the |
750 | following code: |
751 | |
752 | \snippet code/src_core_qcircularbuffer.cpp 19 |
753 | |
754 | After executing the above code, the internal state of the circular buffer |
755 | would look like this: |
756 | |
757 | \img circularbuffer-1.png |
758 | |
759 | As you can see, the internal array has been populated from the beginning. |
760 | The first item is located as position 0 in the array and the last item |
761 | is located at position 4 in the array. The circular buffer is linearized |
762 | because the last item occurs later in the array than the first item. |
763 | |
764 | If we now append another item to the circular buffer with: |
765 | |
766 | \snippet code/src_core_qcircularbuffer.cpp 20 |
767 | |
768 | the internal representation then becomes: |
769 | |
770 | \img circularbuffer-2.png |
771 | |
772 | The circular buffer is still linearized, but it is now full. Appending |
773 | further items will cause the oldest item to be overwritten. For example, |
774 | |
775 | \snippet code/src_core_qcircularbuffer.cpp 21 |
776 | |
777 | causes the internal representation to become: |
778 | |
779 | \img circularbuffer-3.png |
780 | |
781 | We see that the oldest item (1) has been overwritten by the newest item |
782 | (7), and that the first and last indexes have been adjusted accordingly. |
783 | The circular buffer is now said to be non-linearized because the position |
784 | of the last item is before the position of the first item. |
785 | |
786 | The circular buffer can always be linearized by calling the linearise() |
787 | function. This can be an expensive operation (\l{linear time}) for large |
788 | circular buffers since new memory has to be allocated, the items copied across, |
789 | and the original memory deallocated. |
790 | |
791 | If you need to directly access the items stored in a circular buffer, |
792 | (perhaps for a plain C++ function call) then you can use the data() |
793 | function. If the circular buffer is non-linearized, then the data() |
794 | function will linearize it for you before returning an \l array_range |
795 | describing the array. |
796 | |
797 | To prevent the cost of the linearisation process, you can instead |
798 | call the dataOne() and dataTwo() functions to obtain the two arrays |
799 | used to represent a non-linearized circular buffer. After running the |
800 | above sample code, calling the dataOne() function would return an |
801 | \l array_range object describing the values 2-6, and the dataTwo() function |
802 | would return an \l array_range object describing the value 7. Sometimes, |
803 | accessing the items via the two arrays described by dataOne() and dataTwo(), |
804 | can be quicker than calling data() and having the circular buffer |
805 | linearized. The dataOne() and dataTwo() functions do not trigger a |
806 | linearization. |
807 | |
808 | \sa linearise(), data(), dataOne(), dataTwo() |
809 | */ |
810 | |
811 | /* \fn T &Qt3DCore::QCircularBuffer::last() |
812 | |
813 | Returns a reference to the last item in the circular buffer. This |
814 | function assumes that the circular buffer isn't empty. |
815 | |
816 | \sa first(), isEmpty() |
817 | */ |
818 | |
819 | /* \fn const T &Qt3DCore::QCircularBuffer::last() const |
820 | |
821 | \overload |
822 | */ |
823 | |
824 | /* \fn int Qt3DCore::QCircularBuffer::lastIndexOf(const T &value, int from = -1) const |
825 | |
826 | Returns the index position of the last occurrence of the value \a |
827 | value in the circular buffer, searching backward from index position \a |
828 | from. If \a from is -1 (the default), the search starts at the |
829 | last item. Returns -1 if no item is matched. |
830 | |
831 | Example: |
832 | \snippet code/src_core_qcircularbuffer.cpp 16 |
833 | |
834 | This function requires the value type to have an implementation of |
835 | \c operator==(). |
836 | |
837 | \sa indexOf() |
838 | */ |
839 | |
840 | /* \fn void Qt3DCore::QCircularBuffer::linearise() |
841 | |
842 | Linearizes the internal representation of the circular buffer such that |
843 | all items are stored in a single contiguous array. |
844 | |
845 | This function can be expensive for large circular buffers (\l{linear time}). |
846 | |
847 | \sa isLinearised() |
848 | */ |
849 | |
850 | /* \fn void Qt3DCore::QCircularBuffer::prepend(const T &value) |
851 | |
852 | Inserts \a value at the beginning of the circular buffer. If the circular buffer |
853 | is full, then the highest index item is overwritten. |
854 | |
855 | Example: |
856 | \snippet code/src_core_qcircularbuffer.cpp 10 |
857 | |
858 | This operation is very fast, because QCircularBuffer never allocates |
859 | memory in this function. |
860 | |
861 | \sa operator<<(), operator+=(), append(), insert() |
862 | */ |
863 | |
864 | /* \fn void Qt3DCore::QCircularBuffer::remove(int i) |
865 | |
866 | Removes the element at index position \a i. |
867 | |
868 | \sa insert(), replace(), fill() |
869 | */ |
870 | |
871 | /* \fn void Qt3DCore::QCircularBuffer::remove(int i, int count) |
872 | |
873 | \overload |
874 | |
875 | Removes \a count elements from the middle of the circular buffer, |
876 | starting at index position \a i. |
877 | |
878 | \sa insert(), replace(), fill() |
879 | */ |
880 | |
881 | /* \fn void Qt3DCore::QCircularBuffer::replace(int i, const T &value) |
882 | |
883 | Replaces the item at index position \a i with \a value. |
884 | |
885 | \a i must be a valid index position in the circular buffer (i.e., 0 <= \a |
886 | i < size()). |
887 | |
888 | \sa operator[](), remove() |
889 | */ |
890 | |
891 | /* \fn void Qt3DCore::QCircularBuffer::reserve(int capacity) |
892 | |
893 | Sets the capacity of the circular buffer to \a capacity. It is a synonym for |
894 | setCapacity(). |
895 | |
896 | \sa setCapacity() |
897 | */ |
898 | |
899 | /* \fn void Qt3DCore::QCircularBuffer::resize(int size) |
900 | |
901 | Changes the size of the circular buffer to \a size which must be > 0 and |
902 | <= capacity(). If \a size is less than the old size, then the highest indexed |
903 | items are removed. If \a size is greater than the old size, then new items |
904 | with a \l{default-constructed value} are appended to the end of the circular |
905 | buffer. |
906 | |
907 | \sa size(), insert(), remove(), capacity(), setCapacity() |
908 | */ |
909 | |
910 | /* \fn void Qt3DCore::QCircularBuffer::setCapacity(int capacity) |
911 | |
912 | Sets the capacity of the circular buffer to \a capacity. |
913 | |
914 | \sa reserve(), capacity() |
915 | */ |
916 | |
917 | /* \fn int Qt3DCore::QCircularBuffer::size() const |
918 | |
919 | Returns the number of items in the circular buffer. |
920 | |
921 | \sa sizeAvailable(), capacity(), resize() |
922 | */ |
923 | |
924 | /* \fn int Qt3DCore::QCircularBuffer::sizeAvailable() const |
925 | |
926 | Returns the number of items that can be added to the circular buffer |
927 | without causing the earliest item to be overwritten. It is equivalent |
928 | to (capacity() - size()). |
929 | |
930 | \sa capacity(), isEmpty(), isFull(), size(), freeSize() |
931 | */ |
932 | |
933 | /* \fn void Qt3DCore::QCircularBuffer::squeeze() |
934 | |
935 | Releases any unused memory from the circular buffer. It is equivalent |
936 | to calling setCapacity(size()). |
937 | |
938 | \sa setCapacity(), size(), resize(), sizeAvailable() |
939 | */ |
940 | |
941 | /* \fn bool Qt3DCore::QCircularBuffer::startsWith(const T &value) const |
942 | |
943 | Returns \c true if the circular buffer is not empty and its first |
944 | item is equal to \a value; otherwise returns \c false. |
945 | |
946 | \sa isEmpty(), first(), endsWith() |
947 | */ |
948 | |
949 | /* \fn QList<T> Qt3DCore::QCircularBuffer::toList() const |
950 | |
951 | Returns a QList object with the data contained in this QCircularBuffer. |
952 | |
953 | Example: |
954 | |
955 | \snippet code/src_core_qcircularbuffer.cpp 17 |
956 | |
957 | \sa fromList(), toVector() |
958 | */ |
959 | |
960 | /* \fn QVector<T> Qt3DCore::QCircularBuffer::toVector() const |
961 | |
962 | Returns a QVector object with the data contained in this QCircularBuffer. |
963 | |
964 | \sa fromVector(), toList() |
965 | */ |
966 | |
967 | /* \fn T Qt3DCore::QCircularBuffer::value(int i) const |
968 | |
969 | Returns the value at index position \a i in the circular buffer. |
970 | |
971 | If the index \a i is out of bounds, the function returns |
972 | a \l{default-constructed value}. If you are certain that |
973 | \a i is within bounds, you can use at() instead, which is slightly |
974 | faster. |
975 | |
976 | \sa at(), operator[]() |
977 | */ |
978 | |
979 | /* \fn T Qt3DCore::QCircularBuffer::value(int i, const T &defaultValue) const |
980 | |
981 | \overload |
982 | |
983 | If the index \a i is out of bounds, the function returns |
984 | \a defaultValue. |
985 | */ |
986 | |
987 | /* \fn bool Qt3DCore::operator==(const QCircularBuffer<T> &lhs, const QCircularBuffer<T> &rhs) |
988 | |
989 | Returns \c true if the circular buffer \a lhs is equal to \a rhs; otherwise |
990 | returns \c false. |
991 | |
992 | Two circular buffers are considered equal if they contain the same values |
993 | in the same order and have the same capacity. |
994 | |
995 | This function requires the value type to have an implementation |
996 | of \c operator==(). |
997 | |
998 | \sa operator!=() |
999 | */ |
1000 | |
1001 | /* \fn bool Qt3DCore::operator!=(const QCircularBuffer<T> &lhs, const QCircularBuffer<T> &rhs) |
1002 | |
1003 | Returns \c true if the circular buffer \a lhs is not equal to \a rhs; otherwise |
1004 | returns \c false. |
1005 | |
1006 | Two circular buffers are considered equal if they contain the same values |
1007 | in the same order and have the same capacity. |
1008 | |
1009 | This function requires the value type to have an implementation |
1010 | of \c operator==(). |
1011 | |
1012 | \sa operator==() |
1013 | */ |
1014 | |
1015 | /* \fn Qt3DCore::QCircularBuffer<T>& Qt3DCore::QCircularBuffer::operator+=(const T &other) |
1016 | |
1017 | Appends the item \a other to this circular buffer and returns a |
1018 | reference to this circular buffer. |
1019 | |
1020 | \sa operator+(), operator<<(), append() |
1021 | */ |
1022 | |
1023 | /* \fn Qt3DCore::QCircularBuffer<T>& Qt3DCore::QCircularBuffer::operator+=(const QCircularBuffer<T>& other) |
1024 | |
1025 | \overload |
1026 | |
1027 | Appends the items of the \a other circular buffer to this circular |
1028 | buffer and returns a reference to this circular buffer. |
1029 | |
1030 | \sa operator+(), operator<<(), append() |
1031 | */ |
1032 | |
1033 | /* \fn Qt3DCore::QCircularBuffer<T>& Qt3DCore::QCircularBuffer::operator+=(const QVector<T>& other) |
1034 | |
1035 | \overload |
1036 | */ |
1037 | |
1038 | /* \fn Qt3DCore::QCircularBuffer<T>& Qt3DCore::QCircularBuffer::operator+=(const QList<T>& other) |
1039 | |
1040 | \overload |
1041 | */ |
1042 | |
1043 | /* \fn Qt3DCore::QCircularBuffer<T>& Qt3DCore::QCircularBuffer::operator<<(const T &other) |
1044 | |
1045 | Appends the item \a other to this circular buffer and returns a |
1046 | reference to this circular buffer. |
1047 | |
1048 | \sa operator+(), operator+=(), append() |
1049 | */ |
1050 | |
1051 | /* \fn Qt3DCore::QCircularBuffer<T>& Qt3DCore::QCircularBuffer::operator<<(const QCircularBuffer<T>& other) |
1052 | |
1053 | \overload |
1054 | |
1055 | Appends the items of the \a other circular buffer to this circular |
1056 | buffer and returns a reference to this circular buffer. |
1057 | |
1058 | \sa operator+(), operator+=(), append() |
1059 | */ |
1060 | |
1061 | /* \fn Qt3DCore::QCircularBuffer<T>& Qt3DCore::QCircularBuffer::operator<<(const QVector<T>& other) |
1062 | |
1063 | \overload |
1064 | */ |
1065 | |
1066 | /* \fn Qt3DCore::QCircularBuffer<T>& Qt3DCore::QCircularBuffer::operator<<(const QList<T>& other) |
1067 | |
1068 | \overload |
1069 | */ |
1070 | |
1071 | /* \fn Qt3DCore::QCircularBuffer<T> Qt3DCore::operator+(const QCircularBuffer<T>& lhs, const QCircularBuffer<T>& rhs) |
1072 | \relates Qt3DCore::QCircularBuffer |
1073 | |
1074 | Returns a circular buffer object with capacity of lhs.size() + rhs.size() containing |
1075 | the items from \a lhs followed by the items from \a rhs. |
1076 | |
1077 | \sa {QCircularBuffer::}{operator+=()} |
1078 | */ |
1079 | |
1080 | /* \fn void Qt3DCore::swap(QCircularBuffer<T> &lhs, QCircularBuffer<T> &rhs) |
1081 | |
1082 | Swaps the contents of the circular buffer \a lhs with the contents of \a rhs. |
1083 | */ |
1084 | |
1085 | /* \fn bool Qt3DCore::operator<(const QCircularBuffer<T> &lhs, const QCircularBuffer<T> &rhs) |
1086 | |
1087 | Returns \c true if \a lhs is lexographically less than \a rhs. This is equivalent to calling |
1088 | \c{return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end())}. |
1089 | */ |
1090 | |
1091 | /* \fn bool Qt3DCore::operator>(const QCircularBuffer<T> &lhs, const QCircularBuffer<T> &rhs) |
1092 | |
1093 | Returns \c true if \a rhs is lexographically less than \a lhs. |
1094 | */ |
1095 | |
1096 | /* \fn bool Qt3DCore::operator>=(const QCircularBuffer<T> &lhs, const QCircularBuffer<T> &rhs) |
1097 | |
1098 | Returns \c true if \a lhs is lexographically less than or equal to \a rhs. |
1099 | */ |
1100 | |
1101 | /* \fn bool Qt3DCore::operator<=(const QCircularBuffer<T> &lhs, const QCircularBuffer<T> &rhs) |
1102 | |
1103 | Returns \c true if \a lhs is lexographically less than or equal to \a rhs. |
1104 | */ |
1105 | |
1106 | /* \typedef Qt3DCore::QCircularBuffer::Iterator |
1107 | |
1108 | Qt-style synonym for \l iterator. |
1109 | */ |
1110 | |
1111 | /* \typedef Qt3DCore::QCircularBuffer::ConstIterator |
1112 | |
1113 | Qt-style synonym for \l const_iterator. |
1114 | */ |
1115 | |
1116 | /* \typedef Qt3DCore::QCircularBuffer::const_pointer |
1117 | |
1118 | Typedef for const T *. Provided for STL compatibility. |
1119 | */ |
1120 | |
1121 | /* \typedef Qt3DCore::QCircularBuffer::const_reference |
1122 | |
1123 | Typedef for T &. Provided for STL compatibility. |
1124 | */ |
1125 | |
1126 | /* \typedef Qt3DCore::QCircularBuffer::difference_type |
1127 | |
1128 | Typedef for ptrdiff_t. Provided for STL compatibility. |
1129 | */ |
1130 | |
1131 | /* \typedef Qt3DCore::QCircularBuffer::pointer |
1132 | |
1133 | Typedef for T *. Provided for STL compatibility. |
1134 | */ |
1135 | |
1136 | /* \typedef Qt3DCore::QCircularBuffer::reference |
1137 | |
1138 | Typedef for T &. Provided for STL compatibility. |
1139 | */ |
1140 | |
1141 | /* \typedef Qt3DCore::QCircularBuffer::size_type |
1142 | |
1143 | Typedef for int. Provided for STL compatibility. |
1144 | */ |
1145 | |
1146 | /* \typedef Qt3DCore::QCircularBuffer::value_type |
1147 | |
1148 | Typedef for T. Provided for STL compatibility. |
1149 | */ |
1150 | |
1151 | /* \typedef Qt3DCore::QCircularBuffer::array_range |
1152 | |
1153 | Typedef for QPair<T*,int>. The first element is a pointer to the |
1154 | first element of an array of T. The second element is the number |
1155 | of elements in the array. |
1156 | |
1157 | \sa data(), dataOne(), dataTwo() |
1158 | */ |
1159 | |
1160 | /* \typedef Qt3DCore::QCircularBuffer::const_array_range |
1161 | |
1162 | Typedef for QPair<const T*,int>. The first element is a pointer to the |
1163 | first element of an array of const T. The second element is the number |
1164 | of elements in the array. |
1165 | */ |
1166 | |
1167 | /* \typedef Qt3DCore::QCircularBuffer::ArrayRange |
1168 | |
1169 | Qt-style synonym for \l array_range. |
1170 | */ |
1171 | |
1172 | /* \typedef Qt3DCore::QCircularBuffer::ConstArrayRange |
1173 | |
1174 | Qt-style synonym for \l const_array_range. |
1175 | */ |
1176 | |
1177 | |
1178 | /* \class Qt3DCore::QCircularBuffer::iterator |
1179 | \inmodule Qt3DCore |
1180 | \brief The Qt3DCore::QCircularBuffer::iterator class provides an STL-style non-const iterator for QCircularBuffer. |
1181 | |
1182 | QCircularBuffer provides both \l{STL-Style Iterators} and \l{Java-Style |
1183 | Iterators}. |
1184 | |
1185 | \sa begin(), end(), const_iterator |
1186 | */ |
1187 | |
1188 | /* \typedef Qt3DCore::QCircularBuffer::iterator::iterator_category |
1189 | |
1190 | A synonym for \e {std::random_access_iterator_tag} indicating |
1191 | this iterator is a random access iterator. |
1192 | */ |
1193 | |
1194 | /* \typedef Qt3DCore::QCircularBuffer::iterator::difference_type |
1195 | |
1196 | \internal |
1197 | */ |
1198 | |
1199 | /* \typedef Qt3DCore::QCircularBuffer::iterator::value_type |
1200 | |
1201 | \internal |
1202 | */ |
1203 | |
1204 | /* \typedef Qt3DCore::QCircularBuffer::iterator::pointer |
1205 | |
1206 | \internal |
1207 | */ |
1208 | |
1209 | /* \typedef Qt3DCore::QCircularBuffer::iterator::reference |
1210 | |
1211 | \internal |
1212 | */ |
1213 | |
1214 | /* \fn Qt3DCore::QCircularBuffer::iterator::iterator() |
1215 | |
1216 | Constructs an uninitialized iterator. |
1217 | |
1218 | Functions like operator*() and operator++() should not be called |
1219 | on an uninitialized iterator. Use operator=() to assign a value |
1220 | to it before using it. |
1221 | |
1222 | \sa begin(), end() |
1223 | */ |
1224 | |
1225 | /* \fn Qt3DCore::QCircularBuffer::iterator::iterator(QCircularBuffer<T> *buffer, int index) |
1226 | |
1227 | \internal |
1228 | */ |
1229 | |
1230 | /* \fn T &Qt3DCore::QCircularBuffer::iterator::operator*() const |
1231 | |
1232 | Returns a modifiable reference to the current item. |
1233 | |
1234 | You can change the value of an item by using operator*() on the |
1235 | left side of an assignment. |
1236 | |
1237 | \sa operator->() |
1238 | */ |
1239 | |
1240 | /* \fn T *Qt3DCore::QCircularBuffer::iterator::operator->() const |
1241 | |
1242 | Returns a pointer to the current item. |
1243 | |
1244 | \sa operator*() |
1245 | */ |
1246 | |
1247 | /* \fn T &Qt3DCore::QCircularBuffer::iterator::operator[](int j) const |
1248 | |
1249 | Returns a modifiable reference to the item at position *this + |
1250 | \a{j}. |
1251 | |
1252 | This function is provided to make QCircularBuffer iterators behave like C++ |
1253 | pointers. |
1254 | |
1255 | \sa operator+() |
1256 | */ |
1257 | |
1258 | /* |
1259 | \fn bool Qt3DCore::QCircularBuffer::iterator::operator==(const iterator &other) const |
1260 | |
1261 | Returns \c true if \a other points to the same item as this |
1262 | iterator; otherwise returns \c false. |
1263 | |
1264 | \sa operator!=() |
1265 | */ |
1266 | |
1267 | /* |
1268 | \fn bool Qt3DCore::QCircularBuffer::iterator::operator!=(const iterator &other) const |
1269 | |
1270 | Returns \c true if \a other points to a different item than this |
1271 | iterator; otherwise returns \c false. |
1272 | |
1273 | \sa operator==() |
1274 | */ |
1275 | |
1276 | /* |
1277 | \fn bool Qt3DCore::QCircularBuffer::iterator::operator<(const iterator& other) const |
1278 | |
1279 | Returns \c true if the item pointed to by this iterator occurs before |
1280 | the item pointed to by the \a other iterator. |
1281 | */ |
1282 | |
1283 | /* |
1284 | \fn bool Qt3DCore::QCircularBuffer::iterator::operator<=(const iterator& other) const |
1285 | |
1286 | Returns \c true if the item pointed to by this iterator occurs before |
1287 | or at the same position as the item pointed to by the \a other iterator. |
1288 | */ |
1289 | |
1290 | /* |
1291 | \fn bool Qt3DCore::QCircularBuffer::iterator::operator>(const iterator& other) const |
1292 | |
1293 | Returns \c true if the item pointed to by this iterator occurs after |
1294 | the item pointed to by the \a other iterator. |
1295 | */ |
1296 | |
1297 | /* |
1298 | \fn bool Qt3DCore::QCircularBuffer::iterator::operator>=(const iterator& other) const |
1299 | |
1300 | Returns \c true if the item pointed to by this iterator occurs after |
1301 | or at the same position as the item pointed to by the \a other iterator. |
1302 | */ |
1303 | |
1304 | /* \fn Qt3DCore::QCircularBuffer::iterator &Qt3DCore::QCircularBuffer::iterator::operator++() |
1305 | |
1306 | The prefix ++ operator (\c{++it}) advances the iterator to the |
1307 | next item in the circular buffer and returns an iterator to the new current |
1308 | item. |
1309 | |
1310 | Calling this function on end() leads to undefined results. |
1311 | |
1312 | \sa operator--() |
1313 | */ |
1314 | |
1315 | /* \fn Qt3DCore::QCircularBuffer::iterator Qt3DCore::QCircularBuffer::iterator::operator++(int) |
1316 | |
1317 | \overload |
1318 | |
1319 | The postfix ++ operator (\c{it++}) advances the iterator to the |
1320 | next item in the circular buffer and returns an iterator to the previously |
1321 | current item. |
1322 | */ |
1323 | |
1324 | /* \fn Qt3DCore::QCircularBuffer::iterator &Qt3DCore::QCircularBuffer::iterator::operator--() |
1325 | |
1326 | The prefix -- operator (\c{--it}) makes the preceding item |
1327 | the current item, and returns an iterator to the new current item. |
1328 | |
1329 | Calling this function on begin() leads to undefined results. |
1330 | |
1331 | \sa operator++() |
1332 | */ |
1333 | |
1334 | /* \fn Qt3DCore::QCircularBuffer::iterator Qt3DCore::QCircularBuffer::iterator::operator--(int) |
1335 | |
1336 | \overload |
1337 | |
1338 | The postfix -- operator (\c{it--}) makes the preceding item |
1339 | the current item, and returns an iterator to the previously current item. |
1340 | */ |
1341 | |
1342 | /* \fn Qt3DCore::QCircularBuffer::iterator &Qt3DCore::QCircularBuffer::iterator::operator+=(int j) |
1343 | |
1344 | Advances the iterator by \a j items. (If \a j is negative, the |
1345 | iterator goes backward.) |
1346 | |
1347 | \sa operator-=(), operator+() |
1348 | */ |
1349 | |
1350 | /* \fn Qt3DCore::QCircularBuffer::iterator &Qt3DCore::QCircularBuffer::iterator::operator-=(int j) |
1351 | |
1352 | Makes the iterator go back by \a j items. (If \a j is negative, |
1353 | the iterator goes forward.) |
1354 | |
1355 | \sa operator+=(), operator-() |
1356 | */ |
1357 | |
1358 | /* \fn Qt3DCore::QCircularBuffer::iterator Qt3DCore::QCircularBuffer::iterator::operator+(int j) const |
1359 | |
1360 | Returns an iterator to the item at \a j positions forward from |
1361 | this iterator. (If \a j is negative, the iterator goes backward.) |
1362 | |
1363 | \sa operator-(), operator+=() |
1364 | */ |
1365 | |
1366 | /* \fn Qt3DCore::QCircularBuffer::iterator Qt3DCore::QCircularBuffer::iterator::operator-(int j) const |
1367 | |
1368 | Returns an iterator to the item at \a j positions backward from |
1369 | this iterator. (If \a j is negative, the iterator goes forward.) |
1370 | |
1371 | \sa operator+(), operator-=() |
1372 | */ |
1373 | |
1374 | /* \fn int Qt3DCore::QCircularBuffer::iterator::operator-(iterator other) const |
1375 | |
1376 | Returns the number of items between the item pointed to by \a |
1377 | other and the item pointed to by this iterator. |
1378 | */ |
1379 | |
1380 | |
1381 | /* \class Qt3DCore::QCircularBuffer::const_iterator |
1382 | \inmodule Qt3DCore |
1383 | \brief The Qt3DCore::QCircularBuffer::const_iterator class provides an STL-style const iterator for QCircularBuffer. |
1384 | |
1385 | QCircularBuffer provides both \l{STL-Style Iterators} and \l{Java-Style |
1386 | Iterators}. |
1387 | |
1388 | \sa constBegin(), constEnd(), iterator |
1389 | */ |
1390 | |
1391 | /* \typedef Qt3DCore::QCircularBuffer::const_iterator::iterator_category |
1392 | |
1393 | A synonym for \e {std::random_access_iterator_tag} indicating |
1394 | this iterator is a random access iterator. |
1395 | */ |
1396 | |
1397 | /* \typedef Qt3DCore::QCircularBuffer::const_iterator::difference_type |
1398 | |
1399 | \internal |
1400 | */ |
1401 | |
1402 | /* \typedef Qt3DCore::QCircularBuffer::const_iterator::value_type |
1403 | |
1404 | \internal |
1405 | */ |
1406 | |
1407 | /* \typedef Qt3DCore::QCircularBuffer::const_iterator::pointer |
1408 | |
1409 | \internal |
1410 | */ |
1411 | |
1412 | /* \typedef Qt3DCore::QCircularBuffer::const_iterator::reference |
1413 | |
1414 | \internal |
1415 | */ |
1416 | |
1417 | /* \fn Qt3DCore::QCircularBuffer::const_iterator::const_iterator() |
1418 | |
1419 | Constructs an uninitialized const iterator. |
1420 | |
1421 | Functions like operator*() and operator++() should not be called |
1422 | on an uninitialized iterator. Use operator=() to assign a value |
1423 | to it before using it. |
1424 | |
1425 | \sa begin(), end() |
1426 | */ |
1427 | |
1428 | /* \fn Qt3DCore::QCircularBuffer::const_iterator::const_iterator(const iterator &other) |
1429 | |
1430 | \internal |
1431 | */ |
1432 | |
1433 | /* \fn const T &Qt3DCore::QCircularBuffer::const_iterator::operator*() const |
1434 | |
1435 | Returns a const reference to the current item. |
1436 | |
1437 | \sa operator->() |
1438 | */ |
1439 | |
1440 | /* \fn const T *Qt3DCore::QCircularBuffer::const_iterator::operator->() const |
1441 | |
1442 | Returns a pointer to the current item. |
1443 | |
1444 | \sa operator*() |
1445 | */ |
1446 | |
1447 | /* \fn const T &Qt3DCore::QCircularBuffer::const_iterator::operator[](int j) const |
1448 | |
1449 | Returns a const reference to the item at position *this + |
1450 | \a{j}. |
1451 | |
1452 | This function is provided to make QCircularBuffer iterators behave like C++ |
1453 | pointers. |
1454 | |
1455 | \sa operator+() |
1456 | */ |
1457 | |
1458 | /* |
1459 | \fn bool Qt3DCore::QCircularBuffer::const_iterator::operator==(const const_iterator &other) const |
1460 | |
1461 | Returns \c true if \a other points to the same item as this |
1462 | iterator; otherwise returns \c false. |
1463 | |
1464 | \sa operator!=() |
1465 | */ |
1466 | |
1467 | /* |
1468 | \fn bool Qt3DCore::QCircularBuffer::const_iterator::operator!=(const const_iterator &other) const |
1469 | |
1470 | Returns \c true if \a other points to a different item than this |
1471 | iterator; otherwise returns \c false. |
1472 | |
1473 | \sa operator==() |
1474 | */ |
1475 | |
1476 | /* |
1477 | \fn bool Qt3DCore::QCircularBuffer::const_iterator::operator<(const const_iterator& other) const |
1478 | |
1479 | Returns \c true if the item pointed to by this iterator occurs before |
1480 | the item pointed to by the \a other iterator. |
1481 | */ |
1482 | |
1483 | /* |
1484 | \fn bool Qt3DCore::QCircularBuffer::const_iterator::operator<=(const const_iterator& other) const |
1485 | |
1486 | Returns \c true if the item pointed to by this iterator occurs before, |
1487 | or at the same position as the item pointed to by the \a other iterator. |
1488 | */ |
1489 | |
1490 | /* |
1491 | \fn bool Qt3DCore::QCircularBuffer::const_iterator::operator>(const const_iterator& other) const |
1492 | |
1493 | Returns \c true if the item pointed to by this iterator occurs after |
1494 | the item pointed to by the \a other iterator. |
1495 | */ |
1496 | |
1497 | /* |
1498 | \fn bool Qt3DCore::QCircularBuffer::const_iterator::operator>=(const const_iterator& other) const |
1499 | |
1500 | Returns \c true if the item pointed to by this iterator occurs after, |
1501 | or at the same position as the item pointed to by the \a other iterator. |
1502 | */ |
1503 | |
1504 | /* \fn Qt3DCore::QCircularBuffer::const_iterator &Qt3DCore::QCircularBuffer::const_iterator::operator++() |
1505 | |
1506 | The prefix ++ operator (\c{++it}) advances the iterator to the |
1507 | next item in the circular buffer and returns an iterator to the new current |
1508 | item. |
1509 | |
1510 | Calling this function on constEnd() leads to undefined results. |
1511 | |
1512 | \sa operator--() |
1513 | */ |
1514 | |
1515 | /* \fn Qt3DCore::QCircularBuffer::const_iterator Qt3DCore::QCircularBuffer::const_iterator::operator++(int) |
1516 | |
1517 | \overload |
1518 | |
1519 | The postfix ++ operator (\c{it++}) advances the iterator to the |
1520 | next item in the circular buffer and returns an iterator to the previously |
1521 | current item. |
1522 | */ |
1523 | |
1524 | /* \fn Qt3DCore::QCircularBuffer::const_iterator &Qt3DCore::QCircularBuffer::const_iterator::operator--() |
1525 | |
1526 | The prefix -- operator (\c{--it}) makes the preceding item the |
1527 | current and returns an iterator to the new current item. |
1528 | |
1529 | Calling this function on constBegin() leads to undefined results. |
1530 | |
1531 | \sa operator++() |
1532 | */ |
1533 | |
1534 | /* \fn Qt3DCore::QCircularBuffer::const_iterator Qt3DCore::QCircularBuffer::const_iterator::operator--(int) |
1535 | |
1536 | \overload |
1537 | |
1538 | The postfix -- operator (\c{it--}) makes the preceding item the |
1539 | current and returns an iterator to the previously current item. |
1540 | */ |
1541 | |
1542 | /* \fn Qt3DCore::QCircularBuffer::const_iterator &Qt3DCore::QCircularBuffer::const_iterator::operator+=(int j) |
1543 | |
1544 | Advances the iterator by \a j items. (If \a j is negative, the |
1545 | iterator goes backward.) |
1546 | |
1547 | \sa operator-=(), operator+() |
1548 | */ |
1549 | |
1550 | /* \fn Qt3DCore::QCircularBuffer::const_iterator &Qt3DCore::QCircularBuffer::const_iterator::operator-=(int j) |
1551 | |
1552 | Makes the iterator go back by \a j items. (If \a j is negative, |
1553 | the iterator goes forward.) |
1554 | |
1555 | \sa operator+=(), operator-() |
1556 | */ |
1557 | |
1558 | /* \fn Qt3DCore::QCircularBuffer::const_iterator Qt3DCore::QCircularBuffer::const_iterator::operator+(int j) const |
1559 | |
1560 | Returns an iterator to the item at \a j positions forward from |
1561 | this iterator. (If \a j is negative, the iterator goes backward.) |
1562 | |
1563 | \sa operator-(), operator+=() |
1564 | */ |
1565 | |
1566 | /* \fn Qt3DCore::QCircularBuffer::const_iterator Qt3DCore::QCircularBuffer::const_iterator::operator-(int j) const |
1567 | |
1568 | Returns an iterator to the item at \a j positions backward from |
1569 | this iterator. (If \a j is negative, the iterator goes forward.) |
1570 | |
1571 | \sa operator+(), operator-=() |
1572 | */ |
1573 | |
1574 | /* \fn int Qt3DCore::QCircularBuffer::const_iterator::operator-(const_iterator other) const |
1575 | |
1576 | Returns the number of items between the item pointed to by \a |
1577 | other and the item pointed to by this iterator. |
1578 | */ |
1579 |
Warning: That file was not part of the compilation database. It may have many parsing errors.