Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qlist.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// Copyright (C) 2019 Intel Corporation
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QLIST_H
6#define QLIST_H
7
8#include <QtCore/qarraydatapointer.h>
9#include <QtCore/qnamespace.h>
10#include <QtCore/qhashfunctions.h>
11#include <QtCore/qiterator.h>
12#include <QtCore/qcontainertools_impl.h>
13
14#include <functional>
15#include <limits>
16#include <initializer_list>
17#include <type_traits>
18
19class tst_QList;
20
22
23namespace QtPrivate {
24 template <typename V, typename U> qsizetype indexOf(const QList<V> &list, const U &u, qsizetype from) noexcept;
25 template <typename V, typename U> qsizetype lastIndexOf(const QList<V> &list, const U &u, qsizetype from) noexcept;
26}
27
28template <typename T> struct QListSpecialMethodsBase
29{
30protected:
32
33 using Self = QList<T>;
34 Self *self() { return static_cast<Self *>(this); }
35 const Self *self() const { return static_cast<const Self *>(this); }
36
37public:
38 template <typename AT = T>
39 qsizetype indexOf(const AT &t, qsizetype from = 0) const noexcept;
40 template <typename AT = T>
41 qsizetype lastIndexOf(const AT &t, qsizetype from = -1) const noexcept;
42
43 template <typename AT = T>
44 bool contains(const AT &t) const noexcept
45 {
46 return self()->indexOf(t) != -1;
47 }
48};
49template <typename T> struct QListSpecialMethods : QListSpecialMethodsBase<T>
50{
51protected:
53public:
57};
58template <> struct QListSpecialMethods<QByteArray>;
59template <> struct QListSpecialMethods<QString>;
60
61#if !defined(QT_STRICT_QLIST_ITERATORS) && (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)) && !defined(Q_OS_WIN)
62#define QT_STRICT_QLIST_ITERATORS
63#endif
64
65#ifdef Q_QDOC // define QVector for QDoc
66template<typename T> class QVector : public QList<T> {};
67#endif
68
69template <typename T>
70class QList
71#ifndef Q_QDOC
72 : public QListSpecialMethods<T>
73#endif
74{
78 class DisableRValueRefs {};
79
80 friend class ::tst_QList;
81
83
84 template <typename V, typename U> friend qsizetype QtPrivate::indexOf(const QList<V> &list, const U &u, qsizetype from) noexcept;
85 template <typename V, typename U> friend qsizetype QtPrivate::lastIndexOf(const QList<V> &list, const U &u, qsizetype from) noexcept;
86 // This alias prevents the QtPrivate namespace from being exposed into the docs.
87 template <typename InputIterator>
88 using if_input_iterator = QtPrivate::IfIsInputIterator<InputIterator>;
89
90public:
91 using Type = T;
92 using value_type = T;
93 using pointer = T *;
94 using const_pointer = const T *;
95 using reference = T &;
96 using const_reference = const T &;
99#ifndef Q_QDOC
101 using rvalue_ref = typename std::conditional<DataPointer::pass_parameter_by_value, DisableRValueRefs, T &&>::type;
102#else // simplified aliases for QDoc
103 using parameter_type = const T &;
104 using rvalue_ref = T &&;
105#endif
106
107 class const_iterator;
108 class iterator {
109 friend class QList<T>;
110 friend class const_iterator;
111 T *i = nullptr;
112#ifdef QT_STRICT_QLIST_ITERATORS
113 inline constexpr explicit iterator(T *n) : i(n) {}
114#endif
115
116 public:
118 using value_type = T;
119 // libstdc++ shipped with gcc < 11 does not have a fix for defect LWG 3346
120#if __cplusplus >= 202002L && (!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE >= 11)
121 using iterator_concept = std::contiguous_iterator_tag;
122 using element_type = value_type;
123#endif
124 using iterator_category = std::random_access_iterator_tag;
125 using pointer = T *;
126 using reference = T &;
127
128 inline constexpr iterator() = default;
129#ifndef QT_STRICT_QLIST_ITERATORS
130 inline constexpr explicit iterator(T *n) : i(n) {}
131#endif
132 inline T &operator*() const { return *i; }
133 inline T *operator->() const { return i; }
134 inline T &operator[](qsizetype j) const { return *(i + j); }
135 inline constexpr bool operator==(iterator o) const { return i == o.i; }
136 inline constexpr bool operator!=(iterator o) const { return i != o.i; }
137 inline constexpr bool operator<(iterator other) const { return i < other.i; }
138 inline constexpr bool operator<=(iterator other) const { return i <= other.i; }
139 inline constexpr bool operator>(iterator other) const { return i > other.i; }
140 inline constexpr bool operator>=(iterator other) const { return i >= other.i; }
141 inline constexpr bool operator==(const_iterator o) const { return i == o.i; }
142 inline constexpr bool operator!=(const_iterator o) const { return i != o.i; }
143 inline constexpr bool operator<(const_iterator other) const { return i < other.i; }
144 inline constexpr bool operator<=(const_iterator other) const { return i <= other.i; }
145 inline constexpr bool operator>(const_iterator other) const { return i > other.i; }
146 inline constexpr bool operator>=(const_iterator other) const { return i >= other.i; }
147 inline constexpr bool operator==(pointer p) const { return i == p; }
148 inline constexpr bool operator!=(pointer p) const { return i != p; }
149 inline iterator &operator++() { ++i; return *this; }
150 inline iterator operator++(int) { auto copy = *this; ++*this; return copy; }
151 inline iterator &operator--() { --i; return *this; }
152 inline iterator operator--(int) { auto copy = *this; --*this; return copy; }
153 inline qsizetype operator-(iterator j) const { return i - j.i; }
154#if QT_DEPRECATED_SINCE(6, 3) && !defined(QT_STRICT_QLIST_ITERATORS)
155 QT_DEPRECATED_VERSION_X_6_3("Use operator* or operator-> rather than relying on "
156 "the implicit conversion between a QList/QVector::iterator "
157 "and a raw pointer")
158 inline operator T*() const { return i; }
159
160 template <typename Int> std::enable_if_t<std::is_integral_v<Int>, iterator>
161 &operator+=(Int j) { i+=j; return *this; }
162 template <typename Int> std::enable_if_t<std::is_integral_v<Int>, iterator>
163 &operator-=(Int j) { i-=j; return *this; }
164 template <typename Int> std::enable_if_t<std::is_integral_v<Int>, iterator>
165 operator+(Int j) const { return iterator(i+j); }
166 template <typename Int> std::enable_if_t<std::is_integral_v<Int>, iterator>
167 operator-(Int j) const { return iterator(i-j); }
168 template <typename Int> friend std::enable_if_t<std::is_integral_v<Int>, iterator>
169 operator+(Int j, iterator k) { return k + j; }
170#else
171 inline iterator &operator+=(qsizetype j) { i += j; return *this; }
172 inline iterator &operator-=(qsizetype j) { i -= j; return *this; }
173 inline iterator operator+(qsizetype j) const { return iterator(i + j); }
174 inline iterator operator-(qsizetype j) const { return iterator(i - j); }
175 friend inline iterator operator+(qsizetype j, iterator k) { return k + j; }
176#endif
177 };
178
180 friend class QList<T>;
181 friend class iterator;
182 const T *i = nullptr;
183#ifdef QT_STRICT_QLIST_ITERATORS
184 inline constexpr explicit const_iterator(const T *n) : i(n) {}
185#endif
186
187 public:
189 using value_type = T;
190 // libstdc++ shipped with gcc < 11 does not have a fix for defect LWG 3346
191#if __cplusplus >= 202002L && (!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE >= 11)
192 using iterator_concept = std::contiguous_iterator_tag;
193 using element_type = const value_type;
194#endif
195 using iterator_category = std::random_access_iterator_tag;
196 using pointer = const T *;
197 using reference = const T &;
198
199 inline constexpr const_iterator() = default;
200#ifndef QT_STRICT_QLIST_ITERATORS
201 inline constexpr explicit const_iterator(const T *n) : i(n) {}
202#endif
203 inline constexpr const_iterator(iterator o): i(o.i) {}
204 inline const T &operator*() const { return *i; }
205 inline const T *operator->() const { return i; }
206 inline const T &operator[](qsizetype j) const { return *(i + j); }
207 inline constexpr bool operator==(const_iterator o) const { return i == o.i; }
208 inline constexpr bool operator!=(const_iterator o) const { return i != o.i; }
209 inline constexpr bool operator<(const_iterator other) const { return i < other.i; }
210 inline constexpr bool operator<=(const_iterator other) const { return i <= other.i; }
211 inline constexpr bool operator>(const_iterator other) const { return i > other.i; }
212 inline constexpr bool operator>=(const_iterator other) const { return i >= other.i; }
213 inline constexpr bool operator==(iterator o) const { return i == o.i; }
214 inline constexpr bool operator!=(iterator o) const { return i != o.i; }
215 inline constexpr bool operator<(iterator other) const { return i < other.i; }
216 inline constexpr bool operator<=(iterator other) const { return i <= other.i; }
217 inline constexpr bool operator>(iterator other) const { return i > other.i; }
218 inline constexpr bool operator>=(iterator other) const { return i >= other.i; }
219 inline constexpr bool operator==(pointer p) const { return i == p; }
220 inline constexpr bool operator!=(pointer p) const { return i != p; }
221 inline const_iterator &operator++() { ++i; return *this; }
222 inline const_iterator operator++(int) { auto copy = *this; ++*this; return copy; }
223 inline const_iterator &operator--() { --i; return *this; }
224 inline const_iterator operator--(int) { auto copy = *this; --*this; return copy; }
225 inline qsizetype operator-(const_iterator j) const { return i - j.i; }
226#if QT_DEPRECATED_SINCE(6, 3) && !defined(QT_STRICT_QLIST_ITERATORS)
227 QT_DEPRECATED_VERSION_X_6_3("Use operator* or operator-> rather than relying on "
228 "the implicit conversion between a QList/QVector::const_iterator "
229 "and a raw pointer")
230 inline operator const T*() const { return i; }
231
232 template <typename Int> std::enable_if_t<std::is_integral_v<Int>, const_iterator>
233 &operator+=(Int j) { i+=j; return *this; }
234 template <typename Int> std::enable_if_t<std::is_integral_v<Int>, const_iterator>
235 &operator-=(Int j) { i-=j; return *this; }
236 template <typename Int> std::enable_if_t<std::is_integral_v<Int>, const_iterator>
237 operator+(Int j) const { return const_iterator(i+j); }
238 template <typename Int> std::enable_if_t<std::is_integral_v<Int>, const_iterator>
239 operator-(Int j) const { return const_iterator(i-j); }
240 template <typename Int> friend std::enable_if_t<std::is_integral_v<Int>, const_iterator>
241 operator+(Int j, const_iterator k) { return k + j; }
242#else
243 inline const_iterator &operator+=(qsizetype j) { i += j; return *this; }
244 inline const_iterator &operator-=(qsizetype j) { i -= j; return *this; }
245 inline const_iterator operator+(qsizetype j) const { return const_iterator(i + j); }
246 inline const_iterator operator-(qsizetype j) const { return const_iterator(i - j); }
247 friend inline const_iterator operator+(qsizetype j, const_iterator k) { return k + j; }
248#endif
249 };
252 using reverse_iterator = std::reverse_iterator<iterator>;
253 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
254
255private:
256 void resize_internal(qsizetype i);
257 bool isValidIterator(const_iterator i) const
258 {
259 const std::less<const T*> less = {};
260 return !less(d->end(), i.i) && !less(i.i, d->begin());
261 }
262public:
263 QList(DataPointer dd) noexcept
264 : d(dd)
265 {
266 }
267
268public:
269 QList() = default;
271 : d(Data::allocate(size))
272 {
273 if (size)
274 d->appendInitialize(size);
275 }
277 : d(Data::allocate(size))
278 {
279 if (size)
280 d->copyAppend(size, t);
281 }
282
283 inline QList(std::initializer_list<T> args)
284 : d(Data::allocate(qsizetype(args.size())))
285 {
286 if (args.size())
287 d->copyAppend(args.begin(), args.end());
288 }
289
290 QList<T> &operator=(std::initializer_list<T> args)
291 {
293 if (args.size())
294 d->copyAppend(args.begin(), args.end());
295 return *this;
296 }
297
298 template <typename InputIterator, if_input_iterator<InputIterator> = true>
299 QList(InputIterator i1, InputIterator i2)
300 {
301 if constexpr (!std::is_convertible_v<typename std::iterator_traits<InputIterator>::iterator_category, std::forward_iterator_tag>) {
302 std::copy(i1, i2, std::back_inserter(*this));
303 } else {
304 const auto distance = std::distance(i1, i2);
305 if (distance) {
307 // appendIteratorRange can deal with contiguous iterators on its own,
308 // this is an optimization for C++17 code.
309 if constexpr (std::is_same_v<std::decay_t<InputIterator>, iterator> ||
310 std::is_same_v<std::decay_t<InputIterator>, const_iterator>) {
311 d->copyAppend(i1.i, i2.i);
312 } else {
313 d->appendIteratorRange(i1, i2);
314 }
315 }
316 }
317 }
318
319 // This constructor is here for compatibility with QStringList in Qt 5, that has a QStringList(const QString &) constructor
320 template<typename String, typename = std::enable_if_t<std::is_same_v<T, QString> && std::is_convertible_v<String, QString>>>
321 inline explicit QList(const String &str)
322 { append(str); }
323
324 // compiler-generated special member functions are fine!
325
326 void swap(QList &other) noexcept { d.swap(other.d); }
327
328#ifndef Q_QDOC
329 template <typename U = T>
331 {
332 if (size() != other.size())
333 return false;
334 if (begin() == other.begin())
335 return true;
336
337 // do element-by-element comparison
338 return d->compare(data(), other.data(), size());
339 }
340 template <typename U = T>
342 {
343 return !(*this == other);
344 }
345
346 template <typename U = T>
348 noexcept(noexcept(std::lexicographical_compare<typename QList<U>::const_iterator,
349 typename QList::const_iterator>(
350 std::declval<QList<U>>().begin(), std::declval<QList<U>>().end(),
351 other.begin(), other.end())))
352 {
353 return std::lexicographical_compare(begin(), end(),
354 other.begin(), other.end());
355 }
356
357 template <typename U = T>
359 noexcept(noexcept(other < std::declval<QList<U>>()))
360 {
361 return other < *this;
362 }
363
364 template <typename U = T>
366 noexcept(noexcept(other < std::declval<QList<U>>()))
367 {
368 return !(other < *this);
369 }
370
371 template <typename U = T>
373 noexcept(noexcept(std::declval<QList<U>>() < other))
374 {
375 return !(*this < other);
376 }
377#else
378 bool operator==(const QList &other) const;
379 bool operator!=(const QList &other) const;
380 bool operator<(const QList &other) const;
381 bool operator>(const QList &other) const;
382 bool operator<=(const QList &other) const;
383 bool operator>=(const QList &other) const;
384#endif // Q_QDOC
385
386 qsizetype size() const noexcept { return d->size; }
387 qsizetype count() const noexcept { return size(); }
388 qsizetype length() const noexcept { return size(); }
389
390 inline bool isEmpty() const noexcept { return d->size == 0; }
391
393 {
394 resize_internal(size);
395 if (size > this->size())
397 }
399 {
400 resize_internal(size);
401 if (size > this->size())
402 d->copyAppend(size - this->size(), c);
403 }
404
405 inline qsizetype capacity() const { return qsizetype(d->constAllocatedCapacity()); }
407 inline void squeeze();
408
409 void detach() { d.detach(); }
410 bool isDetached() const noexcept { return !d->isShared(); }
411
412 inline bool isSharedWith(const QList<T> &other) const { return d == other.d; }
413
414 pointer data() { detach(); return d->data(); }
415 const_pointer data() const noexcept { return d->data(); }
416 const_pointer constData() const noexcept { return d->data(); }
417 void clear() {
418 if (!size())
419 return;
420 if (d->needsDetach()) {
421 // must allocate memory
422 DataPointer detached(Data::allocate(d.allocatedCapacity()));
423 d.swap(detached);
424 } else {
425 d->truncate(0);
426 }
427 }
428
430 {
431 Q_ASSERT_X(size_t(i) < size_t(d->size), "QList::at", "index out of range");
432 return data()[i];
433 }
435 {
436 Q_ASSERT_X(size_t(i) < size_t(d->size), "QList::operator[]", "index out of range");
437 // don't detach() here, we detach in data below:
438 return data()[i];
439 }
440 const_reference operator[](qsizetype i) const noexcept { return at(i); }
442 void append(const_iterator i1, const_iterator i2);
444 {
446 Q_UNUSED(t);
447 } else {
448 emplaceBack(std::move(t));
449 }
450 }
451 void append(const QList<T> &l)
452 {
453 append(l.constBegin(), l.constEnd());
454 }
455 void append(QList<T> &&l);
458 Q_UNUSED(t);
459 } else {
460 emplaceFront(std::move(t));
461 }
462 }
464
465 template<typename... Args>
466 inline reference emplaceBack(Args &&... args);
467
468 template <typename ...Args>
469 inline reference emplaceFront(Args&&... args);
470
472 { return emplace(i, t); }
475 {
476 Q_ASSERT_X(isValidIterator(before), "QList::insert", "The specified iterator argument 'before' is invalid");
477 return insert(before, 1, t);
478 }
480 {
481 Q_ASSERT_X(isValidIterator(before), "QList::insert", "The specified iterator argument 'before' is invalid");
482 return insert(std::distance(constBegin(), before), n, t);
483 }
485 {
486 Q_ASSERT_X(isValidIterator(before), "QList::insert", "The specified iterator argument 'before' is invalid");
487 return insert(std::distance(constBegin(), before), std::move(t));
488 }
491 Q_UNUSED(i);
492 Q_UNUSED(t);
493 return end();
494 } else {
495 return emplace(i, std::move(t));
496 }
497 }
498
500 {
501 Q_ASSERT(n >= 0);
502 return fill(t, n);
503 }
504
505 template <typename InputIterator, if_input_iterator<InputIterator> = true>
506 QList &assign(InputIterator first, InputIterator last)
507 { d.assign(first, last); return *this; }
508
509 QList &assign(std::initializer_list<T> l)
510 { return assign(l.begin(), l.end()); }
511
512 template <typename ...Args>
514 {
515 Q_ASSERT_X(isValidIterator(before), "QList::emplace", "The specified iterator argument 'before' is invalid");
516 return emplace(std::distance(constBegin(), before), std::forward<Args>(args)...);
517 }
518
519 template <typename ...Args>
520 iterator emplace(qsizetype i, Args&&... args);
521#if 0
522 template< class InputIt >
523 iterator insert( const_iterator pos, InputIt first, InputIt last );
524 iterator insert( const_iterator pos, std::initializer_list<T> ilist );
525#endif
527 {
528 Q_ASSERT_X(i >= 0 && i < d->size, "QList<T>::replace", "index out of range");
529 DataPointer oldData;
530 d.detach(&oldData);
531 d.data()[i] = t;
532 }
534 {
536 Q_UNUSED(i);
537 Q_UNUSED(t);
538 } else {
539 Q_ASSERT_X(i >= 0 && i < d->size, "QList<T>::replace", "index out of range");
540 DataPointer oldData;
541 d.detach(&oldData);
542 d.data()[i] = std::move(t);
543 }
544 }
545
547 void removeFirst() noexcept;
548 void removeLast() noexcept;
549 value_type takeFirst() { Q_ASSERT(!isEmpty()); value_type v = std::move(first()); d->eraseFirst(); return v; }
550 value_type takeLast() { Q_ASSERT(!isEmpty()); value_type v = std::move(last()); d->eraseLast(); return v; }
551
553
554#ifndef Q_QDOC
558#else
559 template <typename AT>
560 qsizetype indexOf(const AT &t, qsizetype from = 0) const noexcept;
561 template <typename AT>
562 qsizetype lastIndexOf(const AT &t, qsizetype from = -1) const noexcept;
563 template <typename AT>
564 bool contains(const AT &t) const noexcept;
565#endif
566
567 template <typename AT = T>
568 qsizetype count(const AT &t) const noexcept
569 {
570 return qsizetype(std::count(data(), data() + size(), t));
571 }
572
574 template <typename AT = T>
576 {
578 }
579
580 template <typename AT = T>
581 bool removeOne(const AT &t)
582 {
583 return QtPrivate::sequential_erase_one(*this, t);
584 }
585
586 template <typename Predicate>
587 qsizetype removeIf(Predicate pred)
588 {
589 return QtPrivate::sequential_erase_if(*this, pred);
590 }
591
592 T takeAt(qsizetype i) { T t = std::move((*this)[i]); remove(i); return t; }
593 void move(qsizetype from, qsizetype to)
594 {
595 Q_ASSERT_X(from >= 0 && from < size(), "QList::move(qsizetype, qsizetype)", "'from' is out-of-range");
596 Q_ASSERT_X(to >= 0 && to < size(), "QList::move(qsizetype, qsizetype)", "'to' is out-of-range");
597 if (from == to) // don't detach when no-op
598 return;
599 detach();
600 T * const b = d->begin();
601 if (from < to)
602 std::rotate(b + from, b + from + 1, b + to + 1);
603 else
604 std::rotate(b + to, b + from, b + from + 1);
605 }
606
607 // STL-style
608 iterator begin() { detach(); return iterator(d->begin()); }
609 iterator end() { detach(); return iterator(d->end()); }
610
611 const_iterator begin() const noexcept { return const_iterator(d->constBegin()); }
612 const_iterator end() const noexcept { return const_iterator(d->constEnd()); }
613 const_iterator cbegin() const noexcept { return const_iterator(d->constBegin()); }
614 const_iterator cend() const noexcept { return const_iterator(d->constEnd()); }
615 const_iterator constBegin() const noexcept { return const_iterator(d->constBegin()); }
616 const_iterator constEnd() const noexcept { return const_iterator(d->constEnd()); }
623
624 iterator erase(const_iterator begin, const_iterator end);
625 inline iterator erase(const_iterator pos) { return erase(pos, pos+1); }
626
627 // more Qt
628 inline T& first() { Q_ASSERT(!isEmpty()); return *begin(); }
629 inline const T &first() const noexcept { Q_ASSERT(!isEmpty()); return *begin(); }
630 inline const T &constFirst() const noexcept { Q_ASSERT(!isEmpty()); return *begin(); }
631 inline T& last() { Q_ASSERT(!isEmpty()); return *(end()-1); }
632 inline const T &last() const noexcept { Q_ASSERT(!isEmpty()); return *(end()-1); }
633 inline const T &constLast() const noexcept { Q_ASSERT(!isEmpty()); return *(end()-1); }
634 inline bool startsWith(parameter_type t) const { return !isEmpty() && first() == t; }
635 inline bool endsWith(parameter_type t) const { return !isEmpty() && last() == t; }
637
639 {
640 Q_ASSERT(size_t(n) <= size_t(size()));
641 return QList<T>(begin(), begin() + n);
642 }
644 {
645 Q_ASSERT(size_t(n) <= size_t(size()));
646 return QList<T>(end() - n, end());
647 }
649 {
650 Q_ASSERT(size_t(pos) <= size_t(size()));
651 return QList<T>(begin() + pos, end());
652 }
654 {
655 Q_ASSERT(size_t(pos) <= size_t(size()));
656 Q_ASSERT(n >= 0);
657 Q_ASSERT(pos + n <= size());
658 return QList<T>(begin() + pos, begin() + pos + n);
659 }
660
661 T value(qsizetype i) const { return value(i, T()); }
662 T value(qsizetype i, parameter_type defaultValue) const;
663
665 Q_ASSERT_X(i >= 0 && i < size() && j >= 0 && j < size(),
666 "QList<T>::swap", "index out of range");
667 detach();
668 qSwap(d->begin()[i], d->begin()[j]);
669 }
670
671 // STL compatibility
672 inline void push_back(parameter_type t) { append(t); }
673 void push_back(rvalue_ref t) { append(std::move(t)); }
674 void push_front(rvalue_ref t) { prepend(std::move(t)); }
676 void pop_back() noexcept { removeLast(); }
677 void pop_front() noexcept { removeFirst(); }
678
679 template <typename ...Args>
680 reference emplace_back(Args&&... args) { return emplaceBack(std::forward<Args>(args)...); }
681
682 inline bool empty() const noexcept
683 { return d->size == 0; }
684 inline reference front() { return first(); }
685 inline const_reference front() const noexcept { return first(); }
686 inline reference back() { return last(); }
687 inline const_reference back() const noexcept { return last(); }
688 void shrink_to_fit() { squeeze(); }
689
690 // comfort
691 QList<T> &operator+=(const QList<T> &l) { append(l); return *this; }
692 QList<T> &operator+=(QList<T> &&l) { append(std::move(l)); return *this; }
693 inline QList<T> operator+(const QList<T> &l) const &
694 { QList n = *this; n += l; return n; }
696 { return std::move(*this += l); }
697 inline QList<T> operator+(QList<T> &&l) const &
698 { QList n = *this; n += std::move(l); return n; }
700 { return std::move(*this += std::move(l)); }
702 { append(t); return *this; }
704 { append(t); return *this; }
705 inline QList<T> &operator<<(const QList<T> &l)
706 { *this += l; return *this; }
707 inline QList<T> &operator<<(QList<T> &&l)
708 { *this += std::move(l); return *this; }
710 { append(std::move(t)); return *this; }
712 { append(std::move(t)); return *this; }
713
714 // Consider deprecating in 6.4 or later
715 static QList<T> fromList(const QList<T> &list) noexcept { return list; }
716 QList<T> toList() const noexcept { return *this; }
717
718 static inline QList<T> fromVector(const QList<T> &vector) noexcept { return vector; }
719 inline QList<T> toVector() const noexcept { return *this; }
720
721 template<qsizetype N>
722 static QList<T> fromReadOnlyData(const T (&t)[N]) noexcept
723 {
724 return QList<T>({ nullptr, const_cast<T *>(t), N });
725 }
726};
727
728template <typename InputIterator,
729 typename ValueType = typename std::iterator_traits<InputIterator>::value_type,
731QList(InputIterator, InputIterator) -> QList<ValueType>;
732
733template <typename T>
734inline void QList<T>::resize_internal(qsizetype newSize)
735{
736 Q_ASSERT(newSize >= 0);
737
738 if (d->needsDetach() || newSize > capacity() - d.freeSpaceAtBegin()) {
739 d.detachAndGrow(QArrayData::GrowsAtEnd, newSize - d.size, nullptr, nullptr);
740 } else if (newSize < size()) {
741 d->truncate(newSize);
742 }
743}
744
745template <typename T>
747{
748 // capacity() == 0 for immutable data, so this will force a detaching below
749 if (asize <= capacity() - d.freeSpaceAtBegin()) {
750 if (d->flags() & Data::CapacityReserved)
751 return; // already reserved, don't shrink
752 if (!d->isShared()) {
753 // accept current allocation, don't shrink
754 d->setFlag(Data::CapacityReserved);
755 return;
756 }
757 }
758
759 DataPointer detached(Data::allocate(qMax(asize, size())));
760 detached->copyAppend(d->begin(), d->end());
761 if (detached.d_ptr())
762 detached->setFlag(Data::CapacityReserved);
763 d.swap(detached);
764}
765
766template <typename T>
767inline void QList<T>::squeeze()
768{
769 if (!d.isMutable())
770 return;
771 if (d->needsDetach() || size() < capacity()) {
772 // must allocate memory
773 DataPointer detached(Data::allocate(size()));
774 if (size()) {
775 if (d.needsDetach())
776 detached->copyAppend(d.data(), d.data() + d.size);
777 else
778 detached->moveAppend(d.data(), d.data() + d.size);
779 }
780 d.swap(detached);
781 }
782 // We're detached so this is fine
783 d->clearFlag(Data::CapacityReserved);
784}
785
786template <typename T>
788{
789 Q_ASSERT_X(size_t(i) + size_t(n) <= size_t(d->size), "QList::remove", "index out of range");
790 Q_ASSERT_X(n >= 0, "QList::remove", "invalid count");
791
792 if (n == 0)
793 return;
794
795 d.detach();
796 d->erase(d->begin() + i, n);
797}
798
799template <typename T>
800inline void QList<T>::removeFirst() noexcept
801{
802 Q_ASSERT(!isEmpty());
803 d.detach();
804 d->eraseFirst();
805}
806
807template <typename T>
808inline void QList<T>::removeLast() noexcept
809{
810 Q_ASSERT(!isEmpty());
811 d.detach();
812 d->eraseLast();
813}
814
815
816template<typename T>
817inline T QList<T>::value(qsizetype i, parameter_type defaultValue) const
818{
819 return size_t(i) < size_t(d->size) ? at(i) : defaultValue;
820}
821
822template <typename T>
824{
825 d->growAppend(i1.i, i2.i);
826}
827
828template <typename T>
830{
831 Q_ASSERT(&other != this);
832 if (other.isEmpty())
833 return;
834 if (other.d->needsDetach() || !std::is_nothrow_move_constructible_v<T>)
835 return append(other);
836
837 // due to precondition &other != this, we can unconditionally modify 'this'
838 d.detachAndGrow(QArrayData::GrowsAtEnd, other.size(), nullptr, nullptr);
839 Q_ASSERT(d.freeSpaceAtEnd() >= other.size());
840 d->moveAppend(other.d->begin(), other.d->end());
841}
842
843template<typename T>
844template<typename... Args>
846{
847 d->emplace(0, std::forward<Args>(args)...);
848 return *d.begin();
849}
850
851
852template <typename T>
853inline typename QList<T>::iterator
855{
856 Q_ASSERT_X(size_t(i) <= size_t(d->size), "QList<T>::insert", "index out of range");
857 Q_ASSERT_X(n >= 0, "QList::insert", "invalid count");
858 if (Q_LIKELY(n))
859 d->insert(i, n, t);
860 return begin() + i;
861}
862
863template <typename T>
864template <typename ...Args>
865typename QList<T>::iterator
867{
868 Q_ASSERT_X(i >= 0 && i <= d->size, "QList<T>::insert", "index out of range");
869 d->emplace(i, std::forward<Args>(args)...);
870 return begin() + i;
871}
872
873template<typename T>
874template<typename... Args>
876{
877 d->emplace(d->size, std::forward<Args>(args)...);
878 return *(end() - 1);
879}
880
881template <typename T>
883{
884 Q_ASSERT_X(isValidIterator(abegin), "QList::erase", "The specified iterator argument 'abegin' is invalid");
885 Q_ASSERT_X(isValidIterator(aend), "QList::erase", "The specified iterator argument 'aend' is invalid");
886 Q_ASSERT(aend >= abegin);
887
888 qsizetype i = std::distance(constBegin(), abegin);
889 qsizetype n = std::distance(abegin, aend);
890 remove(i, n);
891
892 return begin() + i;
893}
894
895template <typename T>
897{
898 if (newSize == -1)
899 newSize = size();
900 if (d->needsDetach() || newSize > capacity()) {
901 // must allocate memory
902 DataPointer detached(Data::allocate(d->detachCapacity(newSize)));
903 detached->copyAppend(newSize, t);
904 d.swap(detached);
905 } else {
906 // we're detached
907 const T copy(t);
908 d->assign(d.begin(), d.begin() + qMin(size(), newSize), t);
909 if (newSize > size()) {
910 d->copyAppend(newSize - size(), copy);
911 } else if (newSize < size()) {
912 d->truncate(newSize);
913 }
914 }
915 return *this;
916}
917
918namespace QtPrivate {
919template <typename T, typename U>
920qsizetype indexOf(const QList<T> &vector, const U &u, qsizetype from) noexcept
921{
922 if (from < 0)
923 from = qMax(from + vector.size(), qsizetype(0));
924 if (from < vector.size()) {
925 auto n = vector.begin() + from - 1;
926 auto e = vector.end();
927 while (++n != e)
928 if (*n == u)
929 return qsizetype(n - vector.begin());
930 }
931 return -1;
932}
933
934template <typename T, typename U>
935qsizetype lastIndexOf(const QList<T> &vector, const U &u, qsizetype from) noexcept
936{
937 if (from < 0)
938 from += vector.d->size;
939 else if (from >= vector.size())
940 from = vector.size() - 1;
941 if (from >= 0) {
942 auto b = vector.begin();
943 auto n = vector.begin() + from + 1;
944 while (n != b) {
945 if (*--n == u)
946 return qsizetype(n - b);
947 }
948 }
949 return -1;
950}
951}
952
953template <typename T>
954template <typename AT>
956{
957 return QtPrivate::indexOf(*self(), t, from);
958}
959
960template <typename T>
961template <typename AT>
963{
964 return QtPrivate::lastIndexOf(*self(), t, from);
965}
966
967template <typename T>
969{
970 qsizetype p = pos;
971 qsizetype l = len;
972 using namespace QtPrivate;
973 switch (QContainerImplHelper::mid(d.size, &p, &l)) {
974 case QContainerImplHelper::Null:
975 case QContainerImplHelper::Empty:
976 return QList();
977 case QContainerImplHelper::Full:
978 return *this;
979 case QContainerImplHelper::Subset:
980 break;
981 }
982
983 // Allocate memory
984 DataPointer copied(Data::allocate(l));
985 copied->copyAppend(data() + p, data() + p + l);
986 return copied;
987}
988
991
992template <typename T>
993size_t qHash(const QList<T> &key, size_t seed = 0)
994 noexcept(noexcept(qHashRange(key.cbegin(), key.cend(), seed)))
995{
996 return qHashRange(key.cbegin(), key.cend(), seed);
997}
998
999template <typename T, typename AT>
1001{
1003}
1004
1005template <typename T, typename Predicate>
1007{
1009}
1010
1011// ### Qt 7 char32_t
1013
1015
1016#include <QtCore/qbytearraylist.h>
1017#include <QtCore/qstringlist.h>
1018
1019#endif // QLIST_H
\inmodule QtCore \reentrant
\inmodule QtCore
Definition qbytearray.h:57
constexpr bool operator==(iterator o) const
Definition qlist.h:213
constexpr bool operator<(iterator other) const
Definition qlist.h:215
constexpr bool operator<(const_iterator other) const
Definition qlist.h:209
const_iterator operator-(qsizetype j) const
Definition qlist.h:246
constexpr bool operator==(pointer p) const
Definition qlist.h:219
const T & reference
Definition qlist.h:197
constexpr bool operator>(const_iterator other) const
Definition qlist.h:211
std::random_access_iterator_tag iterator_category
Definition qlist.h:195
const T & operator[](qsizetype j) const
Definition qlist.h:206
const_iterator & operator-=(qsizetype j)
Definition qlist.h:244
constexpr const_iterator(iterator o)
Definition qlist.h:203
constexpr const_iterator()=default
const T & operator*() const
Definition qlist.h:204
constexpr bool operator!=(const_iterator o) const
Definition qlist.h:208
const_iterator operator+(qsizetype j) const
Definition qlist.h:245
qsizetype difference_type
Definition qlist.h:188
const T * pointer
Definition qlist.h:196
constexpr bool operator<=(iterator other) const
Definition qlist.h:216
const_iterator & operator++()
Definition qlist.h:221
constexpr bool operator!=(pointer p) const
Definition qlist.h:220
constexpr bool operator>(iterator other) const
Definition qlist.h:217
qsizetype operator-(const_iterator j) const
Definition qlist.h:225
constexpr bool operator==(const_iterator o) const
Definition qlist.h:207
constexpr bool operator>=(iterator other) const
Definition qlist.h:218
const_iterator operator--(int)
Definition qlist.h:224
const_iterator & operator--()
Definition qlist.h:223
const_iterator operator++(int)
Definition qlist.h:222
constexpr bool operator!=(iterator o) const
Definition qlist.h:214
const_iterator & operator+=(qsizetype j)
Definition qlist.h:243
friend const_iterator operator+(qsizetype j, const_iterator k)
Definition qlist.h:247
constexpr bool operator<=(const_iterator other) const
Definition qlist.h:210
const T * operator->() const
Definition qlist.h:205
constexpr bool operator>=(const_iterator other) const
Definition qlist.h:212
constexpr bool operator>(iterator other) const
Definition qlist.h:139
iterator operator+(qsizetype j) const
Definition qlist.h:173
iterator & operator-=(qsizetype j)
Definition qlist.h:172
T & operator[](qsizetype j) const
Definition qlist.h:134
iterator & operator++()
Definition qlist.h:149
constexpr bool operator<(const_iterator other) const
Definition qlist.h:143
constexpr bool operator!=(pointer p) const
Definition qlist.h:148
constexpr bool operator<=(iterator other) const
Definition qlist.h:138
qsizetype difference_type
Definition qlist.h:117
constexpr bool operator!=(iterator o) const
Definition qlist.h:136
constexpr bool operator<=(const_iterator other) const
Definition qlist.h:144
T & operator*() const
Definition qlist.h:132
iterator operator++(int)
Definition qlist.h:150
constexpr bool operator>(const_iterator other) const
Definition qlist.h:145
constexpr bool operator>=(iterator other) const
Definition qlist.h:140
constexpr bool operator<(iterator other) const
Definition qlist.h:137
friend iterator operator+(qsizetype j, iterator k)
Definition qlist.h:175
std::random_access_iterator_tag iterator_category
Definition qlist.h:124
constexpr bool operator!=(const_iterator o) const
Definition qlist.h:142
constexpr bool operator==(const_iterator o) const
Definition qlist.h:141
constexpr bool operator>=(const_iterator other) const
Definition qlist.h:146
qsizetype operator-(iterator j) const
Definition qlist.h:153
iterator & operator--()
Definition qlist.h:151
constexpr iterator()=default
T * operator->() const
Definition qlist.h:133
iterator operator-(qsizetype j) const
Definition qlist.h:174
constexpr bool operator==(iterator o) const
Definition qlist.h:135
iterator & operator+=(qsizetype j)
Definition qlist.h:171
constexpr bool operator==(pointer p) const
Definition qlist.h:147
iterator operator--(int)
Definition qlist.h:152
Definition qlist.h:74
void append(const_iterator i1, const_iterator i2)
Definition qlist.h:823
void pop_back() noexcept
Definition qlist.h:676
iterator insert(const_iterator before, parameter_type t)
Definition qlist.h:474
qsizetype size() const noexcept
Definition qlist.h:386
void removeFirst() noexcept
Definition qlist.h:800
QList< T > & fill(parameter_type t, qsizetype size=-1)
Definition qlist.h:896
const_pointer constData() const noexcept
Definition qlist.h:416
void push_front(rvalue_ref t)
Definition qlist.h:674
bool isEmpty() const noexcept
Definition qlist.h:390
T & first()
Definition qlist.h:628
T & last()
Definition qlist.h:631
typename std::conditional< DataPointer::pass_parameter_by_value, DisableRValueRefs, T && >::type rvalue_ref
Definition qlist.h:101
QList(const String &str)
Definition qlist.h:321
void replace(qsizetype i, rvalue_ref t)
Definition qlist.h:533
const_iterator begin() const noexcept
Definition qlist.h:611
void push_back(rvalue_ref t)
Definition qlist.h:673
bool isDetached() const noexcept
Definition qlist.h:410
void removeAt(qsizetype i)
Definition qlist.h:573
reference back()
Definition qlist.h:686
QList< T > last(qsizetype n) const
Definition qlist.h:643
bool isSharedWith(const QList< T > &other) const
Definition qlist.h:412
iterator insert(const_iterator before, rvalue_ref t)
Definition qlist.h:484
QList< T > & operator+=(const QList< T > &l)
Definition qlist.h:691
QList< T > operator+(const QList< T > &l) &&
Definition qlist.h:695
reference emplaceFront(Args &&... args)
Definition qlist.h:845
reference emplace_back(Args &&... args)
Definition qlist.h:680
const T & constLast() const noexcept
Definition qlist.h:633
iterator erase(const_iterator begin, const_iterator end)
Definition qlist.h:882
QList< T > sliced(qsizetype pos, qsizetype n) const
Definition qlist.h:653
QList(std::initializer_list< T > args)
Definition qlist.h:283
QTypeTraits::compare_eq_result_container< QList, U > operator==(const QList &other) const
Definition qlist.h:330
QList(qsizetype size)
Definition qlist.h:270
iterator insert(qsizetype i, parameter_type t)
Definition qlist.h:471
QTypeTraits::compare_lt_result_container< QList, U > operator<=(const QList &other) const noexcept(noexcept(other< std::declval< QList< U > >()))
Definition qlist.h:365
bool empty() const noexcept
Definition qlist.h:682
bool removeOne(const AT &t)
Definition qlist.h:581
QList< T > toList() const noexcept
Definition qlist.h:716
QList(InputIterator i1, InputIterator i2)
Definition qlist.h:299
QList< T > & operator+=(rvalue_ref t)
Definition qlist.h:709
static QList< T > fromReadOnlyData(const T(&t)[N]) noexcept
Definition qlist.h:722
static QList< T > fromList(const QList< T > &list) noexcept
Definition qlist.h:715
QList(qsizetype size, parameter_type t)
Definition qlist.h:276
const_reference back() const noexcept
Definition qlist.h:687
qsizetype capacity() const
Definition qlist.h:405
QTypeTraits::compare_lt_result_container< QList, U > operator<(const QList &other) const noexcept(noexcept(std::lexicographical_compare< typename QList< U >::const_iterator, typename QList::const_iterator >(std::declval< QList< U > >().begin(), std::declval< QList< U > >().end(), other.begin(), other.end())))
Definition qlist.h:347
void swapItemsAt(qsizetype i, qsizetype j)
Definition qlist.h:664
void push_back(parameter_type t)
Definition qlist.h:672
void shrink_to_fit()
Definition qlist.h:688
QList< T > operator+(const QList< T > &l) const &
Definition qlist.h:693
void detach()
Definition qlist.h:409
const_iterator end() const noexcept
Definition qlist.h:612
iterator erase(const_iterator pos)
Definition qlist.h:625
bool endsWith(parameter_type t) const
Definition qlist.h:635
qsizetype count(const AT &t) const noexcept
Definition qlist.h:568
bool startsWith(parameter_type t) const
Definition qlist.h:634
const T * const_pointer
Definition qlist.h:94
friend qsizetype QtPrivate::lastIndexOf(const QList< V > &list, const U &u, qsizetype from) noexcept
iterator end()
Definition qlist.h:609
qptrdiff difference_type
Definition qlist.h:98
QList< T > operator+(QList< T > &&l) &&
Definition qlist.h:699
T takeAt(qsizetype i)
Definition qlist.h:592
typename DataPointer::parameter_type parameter_type
Definition qlist.h:100
qsizetype length() const noexcept
Definition qlist.h:388
std::reverse_iterator< iterator > reverse_iterator
Definition qlist.h:252
const_reference at(qsizetype i) const noexcept
Definition qlist.h:429
value_type takeFirst()
Definition qlist.h:549
iterator insert(qsizetype i, rvalue_ref t)
Definition qlist.h:489
QList< T > & operator<<(parameter_type t)
Definition qlist.h:703
QList< T > sliced(qsizetype pos) const
Definition qlist.h:648
QList< T > toVector() const noexcept
Definition qlist.h:719
T value(qsizetype i) const
Definition qlist.h:661
void prepend(parameter_type t)
Definition qlist.h:463
void swap(QList &other) noexcept
Definition qlist.h:326
iterator insert(const_iterator before, qsizetype n, parameter_type t)
Definition qlist.h:479
QList< T > & operator=(std::initializer_list< T > args)
Definition qlist.h:290
void move(qsizetype from, qsizetype to)
Definition qlist.h:593
QList(DataPointer dd) noexcept
Definition qlist.h:263
const_reverse_iterator crbegin() const noexcept
Definition qlist.h:621
T * pointer
Definition qlist.h:93
reference operator[](qsizetype i)
Definition qlist.h:434
void append(rvalue_ref t)
Definition qlist.h:443
const_iterator constBegin() const noexcept
Definition qlist.h:615
const_reference operator[](qsizetype i) const noexcept
Definition qlist.h:440
const_reverse_iterator rbegin() const noexcept
Definition qlist.h:619
void remove(qsizetype i, qsizetype n=1)
Definition qlist.h:787
value_type takeLast()
Definition qlist.h:550
qsizetype size_type
Definition qlist.h:97
qsizetype removeIf(Predicate pred)
Definition qlist.h:587
reference front()
Definition qlist.h:684
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition qlist.h:253
qsizetype removeAll(const AT &t)
Definition qlist.h:575
iterator emplace(qsizetype i, Args &&... args)
Definition qlist.h:866
const T & first() const noexcept
Definition qlist.h:629
iterator insert(qsizetype i, qsizetype n, parameter_type t)
Definition qlist.h:854
void push_front(parameter_type t)
Definition qlist.h:675
void append(QList< T > &&l)
Definition qlist.h:829
T & reference
Definition qlist.h:95
qsizetype count() const noexcept
Definition qlist.h:387
void squeeze()
Definition qlist.h:767
reference emplaceBack(Args &&... args)
Definition qlist.h:875
QList< T > mid(qsizetype pos, qsizetype len=-1) const
Definition qlist.h:968
reverse_iterator rend()
Definition qlist.h:618
QTypeTraits::compare_lt_result_container< QList, U > operator>(const QList &other) const noexcept(noexcept(other< std::declval< QList< U > >()))
Definition qlist.h:358
T value_type
Definition qlist.h:92
void prepend(rvalue_ref t)
Definition qlist.h:456
QList< T > operator+(QList< T > &&l) const &
Definition qlist.h:697
QList & assign(std::initializer_list< T > l)
Definition qlist.h:509
iterator begin()
Definition qlist.h:608
void resize(qsizetype size, parameter_type c)
Definition qlist.h:398
QList< T > first(qsizetype n) const
Definition qlist.h:638
const T & constFirst() const noexcept
Definition qlist.h:630
iterator emplace(const_iterator before, Args &&... args)
Definition qlist.h:513
void reserve(qsizetype size)
Definition qlist.h:746
QList & assign(InputIterator first, InputIterator last)
Definition qlist.h:506
static QList< T > fromVector(const QList< T > &vector) noexcept
Definition qlist.h:718
void replace(qsizetype i, parameter_type t)
Definition qlist.h:526
reverse_iterator rbegin()
Definition qlist.h:617
void pop_front() noexcept
Definition qlist.h:677
pointer data()
Definition qlist.h:414
const T & const_reference
Definition qlist.h:96
const T & last() const noexcept
Definition qlist.h:632
void removeLast() noexcept
Definition qlist.h:808
void resize(qsizetype size)
Definition qlist.h:392
T Type
Definition qlist.h:91
const_iterator cend() const noexcept
Definition qlist.h:614
void append(parameter_type t)
Definition qlist.h:441
QList< T > & operator+=(parameter_type t)
Definition qlist.h:701
QTypeTraits::compare_eq_result_container< QList, U > operator!=(const QList &other) const
Definition qlist.h:341
const_iterator constEnd() const noexcept
Definition qlist.h:616
const_reverse_iterator rend() const noexcept
Definition qlist.h:620
T value(qsizetype i, parameter_type defaultValue) const
Definition qlist.h:817
const_iterator cbegin() const noexcept
Definition qlist.h:613
QList & assign(qsizetype n, parameter_type t)
Definition qlist.h:499
QTypeTraits::compare_lt_result_container< QList, U > operator>=(const QList &other) const noexcept(noexcept(std::declval< QList< U > >()< other))
Definition qlist.h:372
const_pointer data() const noexcept
Definition qlist.h:415
void clear()
Definition qlist.h:417
const_reference front() const noexcept
Definition qlist.h:685
QList< T > & operator+=(QList< T > &&l)
Definition qlist.h:692
friend qsizetype QtPrivate::indexOf(const QList< V > &list, const U &u, qsizetype from) noexcept
void append(const QList< T > &l)
Definition qlist.h:451
QList()=default
const_reverse_iterator crend() const noexcept
Definition qlist.h:622
QList< uint > toUcs4() const
Returns a UCS-4/UTF-32 representation of the string view as a QList<uint>.
Definition qlist.h:1012
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
QString str
[2]
qSwap(pi, e)
list append(new Employee("Blackpool", "Stephen"))
double e
Combined button and popup list for selecting options.
std::enable_if_t< std::conjunction_v< QTypeTraits::has_operator_equal_container< Container, T >... >, bool > compare_eq_result_container
Definition qtypeinfo.h:320
std::enable_if_t< std::conjunction_v< QTypeTraits::has_operator_less_than_container< Container, T >... >, bool > compare_lt_result_container
Definition qtypeinfo.h:326
\macro QT_NAMESPACE
auto sequential_erase_one(Container &c, const T &t)
Q_CORE_EXPORT QList< uint > convertToUcs4(QStringView str)
auto sequential_erase_if(Container &c, Predicate &pred)
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype lastIndexOf(QByteArrayView haystack, qsizetype from, QByteArrayView needle) noexcept
auto sequential_erase_with_copy(Container &c, const T &t)
auto sequential_erase(Container &c, const T &t)
typename std::enable_if< std::is_convertible< typename std::iterator_traits< Iterator >::iterator_category, std::input_iterator_tag >::value, bool >::type IfIsInputIterator
qsizetype indexOf(const QList< V > &list, const U &u, qsizetype from) noexcept
static jboolean copy(JNIEnv *, jobject)
#define Q_LIKELY(x)
size_t qHashRange(InputIterator first, InputIterator last, size_t seed=0) noexcept(noexcept(qHash(*first)))
NSUInteger capacity
#define Q_DECLARE_SEQUENTIAL_ITERATOR(C)
Definition qiterator.h:20
#define Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(C)
Definition qiterator.h:52
qsizetype erase(QList< T > &list, const AT &t)
Definition qlist.h:1000
qsizetype erase_if(QList< T > &list, Predicate pred)
Definition qlist.h:1006
size_t qHash(const QList< T > &key, size_t seed=0) noexcept(noexcept(qHashRange(key.cbegin(), key.cend(), seed)))
Definition qlist.h:993
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLuint64 key
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLuint end
GLsizei GLsizei GLfloat distance
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint first
GLfloat n
const GLubyte * c
GLenum GLsizei len
GLdouble GLdouble t
Definition qopenglext.h:243
GLfloat GLfloat p
[1]
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define Q_ASSERT_X(cond, x, msg)
Definition qrandom.cpp:48
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
#define AT
#define QT_DEPRECATED_VERSION_X_6_3(text)
#define Q_UNUSED(x)
ptrdiff_t qptrdiff
Definition qtypes.h:69
ptrdiff_t qsizetype
Definition qtypes.h:70
QList< int > list
[14]
QList< int > vector
[14]
settings remove("monkey")
QSharedPointer< T > other(t)
[5]
QAction * at
QJSValueList args
void setFlag(typename Data::ArrayOptions f) noexcept
std::conditional< pass_parameter_by_value, T, constT & >::type parameter_type
Data * d_ptr() noexcept
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept
Definition qlist.h:955
const Self * self() const
Definition qlist.h:35
~QListSpecialMethodsBase()=default
bool contains(const AT &t) const noexcept
Definition qlist.h:44
qsizetype lastIndexOf(const AT &t, qsizetype from=-1) const noexcept
Definition qlist.h:962
~QListSpecialMethods()=default
static QPair< QTypedArrayData *, T * > allocate(qsizetype capacity, AllocationOption option=QArrayData::KeepSize)
Definition qarraydata.h:101
void appendInitialize(qsizetype newSize)
void copyAppend(const T *b, const T *e)