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#include <QtCore/qnamespace.h>
17#include <initializer_list>
36 const Self *
self()
const {
return static_cast<const Self *
>(
this); }
39 template <
typename AT = T>
41 template <typename
AT = T>
44 template <typename
AT = T>
62#if !defined(QT_STRICT_QLIST_ITERATORS) && (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)) && !defined(Q_OS_WIN)
63#define QT_STRICT_QLIST_ITERATORS
76 using Data = QTypedArrayData<T>;
77 using DataOps = QArrayDataOps<T>;
79 class DisableRValueRefs {};
81 friend class ::tst_QList;
88 template <
typename InputIterator>
102 using rvalue_ref =
typename std::conditional<DataPointer::pass_parameter_by_value, DisableRValueRefs, T &&>::type;
110 friend class QList<T>;
113#ifdef QT_STRICT_QLIST_ITERATORS
120#ifdef QT_COMPILER_HAS_LWG3346
121 using iterator_concept = std::contiguous_iterator_tag;
129#ifndef QT_STRICT_QLIST_ITERATORS
154#if QT_DEPRECATED_SINCE(6, 3) && !defined(QT_STRICT_QLIST_ITERATORS)
156 "the implicit conversion between a QList/QVector::iterator "
158 inline operator T*()
const {
return i; }
160 template <
typename Int> std::enable_if_t<std::is_integral_v<Int>,
iterator>
162 template <
typename Int> std::enable_if_t<std::is_integral_v<Int>,
iterator>
164 template <
typename Int> std::enable_if_t<std::is_integral_v<Int>,
iterator>
166 template <
typename Int> std::enable_if_t<std::is_integral_v<Int>,
iterator>
168 template <
typename Int>
friend std::enable_if_t<std::is_integral_v<Int>,
iterator>
180 friend class QList<T>;
182 const T *
i =
nullptr;
183#ifdef QT_STRICT_QLIST_ITERATORS
190#ifdef QT_COMPILER_HAS_LWG3346
191 using iterator_concept = std::contiguous_iterator_tag;
199#ifndef QT_STRICT_QLIST_ITERATORS
225#if QT_DEPRECATED_SINCE(6, 3) && !defined(QT_STRICT_QLIST_ITERATORS)
227 "the implicit conversion between a QList/QVector::const_iterator "
229 inline operator const T*()
const {
return i; }
231 template <
typename Int> std::enable_if_t<std::is_integral_v<Int>,
const_iterator>
233 template <
typename Int> std::enable_if_t<std::is_integral_v<Int>,
const_iterator>
235 template <
typename Int> std::enable_if_t<std::is_integral_v<Int>,
const_iterator>
237 template <
typename Int> std::enable_if_t<std::is_integral_v<Int>,
const_iterator>
239 template <
typename Int>
friend std::enable_if_t<std::is_integral_v<Int>,
const_iterator>
258 const std::less<const T*> less = {};
259 return !less(
d->end(),
i.i) && !less(
i.i,
d->begin());
281 d->appendInitialize(
size);
302 template <
typename InputIterator, if_input_iterator<InputIterator> = true>
303 QList(InputIterator i1, InputIterator i2)
305 if constexpr (!std::is_convertible_v<typename std::iterator_traits<InputIterator>::iterator_category, std::forward_iterator_tag>) {
306 std::copy(i1, i2, std::back_inserter(*
this));
308 const auto distance = std::distance(i1, i2);
313 if constexpr (std::is_same_v<std::decay_t<InputIterator>,
iterator> ||
315 d->copyAppend(i1.i, i2.i);
317 d->appendIteratorRange(i1, i2);
324 template<
typename String,
typename = std::enable_if_t<std::is_same_v<T, QString> && std::is_convertible_v<String, QString>>>
332 d->appendUninitialized(
size);
340 template <
typename U = T>
351 template <
typename U = T>
354 return !(*
this ==
other);
357 template <
typename U = T>
359 noexcept(
noexcept(std::lexicographical_compare<typename QList<U>::const_iterator,
361 std::declval<QList<U>>().
begin(), std::declval<QList<U>>().
end(),
364 return std::lexicographical_compare(
begin(),
end(),
368 template <
typename U = T>
370 noexcept(
noexcept(other < std::declval<QList<U>>()))
372 return other < *
this;
375 template <
typename U = T>
377 noexcept(
noexcept(other < std::declval<QList<U>>()))
379 return !(
other < *
this);
382 template <
typename U = T>
384 noexcept(
noexcept(std::declval<QList<U>>() <
other))
386 return !(*
this <
other);
401 inline bool isEmpty() const noexcept {
return d->size == 0; }
405 resize_internal(
size);
407 d->appendInitialize(
size);
411 resize_internal(
size);
413 d->copyAppend(
size - this->
size(), c);
417 resize_internal(
size);
419 d->appendUninitialized(
size);
437 if (
d->needsDetach()) {
448 Q_ASSERT_X(
size_t(
i) <
size_t(
d->size),
"QList::at",
"index out of range");
453 Q_ASSERT_X(
size_t(
i) <
size_t(
d->size),
"QList::operator[]",
"index out of range");
459 void append(const_iterator i1, const_iterator i2);
470 append(l.constBegin(), l.constEnd());
482 template<
typename... Args>
485 template <
typename ...Args>
493 Q_ASSERT_X(isValidIterator(before),
"QList::insert",
"The specified iterator argument 'before' is invalid");
498 Q_ASSERT_X(isValidIterator(before),
"QList::insert",
"The specified iterator argument 'before' is invalid");
503 Q_ASSERT_X(isValidIterator(before),
"QList::insert",
"The specified iterator argument 'before' is invalid");
522 template <
typename InputIterator, if_input_iterator<InputIterator> = true>
527 {
return assign(l.begin(), l.end()); }
529 template <
typename ...Args>
532 Q_ASSERT_X(isValidIterator(before),
"QList::emplace",
"The specified iterator argument 'before' is invalid");
536 template <
typename ...Args>
539 template<
class InputIt >
541 iterator
insert( const_iterator
pos, std::initializer_list<T> ilist );
545 Q_ASSERT_X(
i >= 0 && i < d->
size,
"QList<T>::replace",
"index out of range");
556 Q_ASSERT_X(
i >= 0 && i < d->
size,
"QList<T>::replace",
"index out of range");
559 d.data()[
i] = std::move(
t);
576 template <
typename AT>
578 template <typename
AT>
580 template <typename
AT>
584 template <
typename AT = T>
591 template <
typename AT = T>
597 template <
typename AT = T>
603 template <
typename Predicate>
612 Q_ASSERT_X(from >= 0 && from <
size(),
"QList::move(qsizetype, qsizetype)",
"'from' is out-of-range");
613 Q_ASSERT_X(to >= 0 && to <
size(),
"QList::move(qsizetype, qsizetype)",
"'to' is out-of-range");
617 T *
const b =
d->begin();
619 std::rotate(
b + from,
b + from + 1,
b + to + 1);
621 std::rotate(
b + to,
b + from,
b + from + 1);
656 { verify(0,
n);
return QList<T>(
begin(),
begin() +
n); }
658 { verify(0,
n);
return QList<T>(
end() -
n,
end()); }
669 "QList<T>::swap",
"index out of range");
682 template <
typename ...Args>
686 {
return d->size == 0; }
694 return Data::max_size();
701 {
QList n = *
this;
n += l;
return n; }
703 {
return std::move(*
this += l); }
705 {
QList n = *
this;
n += std::move(l);
return n; }
707 {
return std::move(*
this += std::move(l)); }
712 inline QList<T> &
operator<<(
const QList<T> &l)
713 { *
this += l;
return *
this; }
715 { *
this += std::move(l);
return *
this; }
717 {
append(std::move(
t));
return *
this; }
719 {
append(std::move(
t));
return *
this; }
723 QList<T>
toList() const noexcept {
return *
this; }
726 inline QList<T>
toVector() const noexcept {
return *
this; }
728 template<qsizetype N>
731 return QList<T>({
nullptr,
const_cast<T *
>(
t), N });
735template <
typename InputIterator,
736 typename ValueType =
typename std::iterator_traits<InputIterator>::value_type,
738QList(InputIterator, InputIterator) -> QList<ValueType>;
745 if (
d->needsDetach() || newSize >
capacity() -
d.freeSpaceAtBegin()) {
747 }
else if (newSize <
size()) {
748 d->truncate(newSize);
756 if (asize <=
capacity() -
d.freeSpaceAtBegin()) {
757 if (
d->flags() & Data::CapacityReserved)
759 if (!
d->isShared()) {
761 d->setFlag(Data::CapacityReserved);
767 detached->copyAppend(
d->begin(),
d->end());
768 if (detached.
d_ptr())
769 detached->setFlag(Data::CapacityReserved);
783 detached->copyAppend(
d.data(),
d.data() +
d.size);
785 detached->moveAppend(
d.data(),
d.data() +
d.size);
790 d->clearFlag(Data::CapacityReserved);
796 Q_ASSERT_X(
size_t(
i) +
size_t(
n) <=
size_t(
d->size),
"QList::remove",
"index out of range");
797 Q_ASSERT_X(
n >= 0,
"QList::remove",
"invalid count");
803 d->erase(
d->begin() +
i,
n);
826 return size_t(
i) < size_t(
d->size) ?
at(
i) : defaultValue;
832 d->growAppend(i1.i, i2.i);
841 if (
other.d->needsDetach() || !std::is_nothrow_move_constructible_v<T>)
851template<
typename... Args>
854 d->emplace(0, std::forward<Args>(
args)...);
863 Q_ASSERT_X(
size_t(
i) <=
size_t(
d->size),
"QList<T>::insert",
"index out of range");
864 Q_ASSERT_X(
n >= 0,
"QList::insert",
"invalid count");
871template <
typename ...Args>
875 Q_ASSERT_X(
i >= 0 && i <= d->
size,
"QList<T>::insert",
"index out of range");
876 d->emplace(
i, std::forward<Args>(
args)...);
881template<
typename... Args>
884 d->emplace(
d->size, std::forward<Args>(
args)...);
891 Q_ASSERT_X(isValidIterator(abegin),
"QList::erase",
"The specified iterator argument 'abegin' is invalid");
892 Q_ASSERT_X(isValidIterator(aend),
"QList::erase",
"The specified iterator argument 'aend' is invalid");
895 qsizetype i = std::distance(constBegin(), abegin);
907 if (
d->needsDetach() || newSize >
capacity()) {
910 detached->copyAppend(newSize,
t);
915 d->assign(
d.begin(),
d.begin() +
qMin(
size(), newSize),
t);
916 if (newSize >
size()) {
918 }
else if (newSize <
size()) {
919 d->truncate(newSize);
926template <
typename T,
typename U>
941template <
typename T,
typename U>
961template <
typename AT>
968template <
typename AT>
980 switch (QContainerImplHelper::mid(
d.size, &
p, &l)) {
981 case QContainerImplHelper::Null:
982 case QContainerImplHelper::Empty:
984 case QContainerImplHelper::Full:
986 case QContainerImplHelper::Subset:
992 copied->copyAppend(
data() +
p,
data() +
p + l);
1006template <
typename T,
typename AT>
1012template <
typename T,
typename Predicate>
1023#include <QtCore/qbytearraylist.h>
1024#include <QtCore/qstringlist.h>
\inmodule QtCore \reentrant
constexpr bool operator==(iterator o) const
constexpr bool operator<(iterator other) const
constexpr bool operator<(const_iterator other) const
const_iterator operator-(qsizetype j) const
constexpr bool operator==(pointer p) const
constexpr bool operator>(const_iterator other) const
std::random_access_iterator_tag iterator_category
const T & operator[](qsizetype j) const
const_iterator & operator-=(qsizetype j)
constexpr const_iterator(iterator o)
constexpr const_iterator()=default
const T & operator*() const
constexpr bool operator!=(const_iterator o) const
const_iterator operator+(qsizetype j) const
qsizetype difference_type
constexpr bool operator<=(iterator other) const
const_iterator & operator++()
constexpr bool operator!=(pointer p) const
constexpr bool operator>(iterator other) const
qsizetype operator-(const_iterator j) const
constexpr bool operator==(const_iterator o) const
constexpr bool operator>=(iterator other) const
const_iterator operator--(int)
const_iterator & operator--()
const_iterator operator++(int)
constexpr bool operator!=(iterator o) const
const_iterator & operator+=(qsizetype j)
friend const_iterator operator+(qsizetype j, const_iterator k)
constexpr bool operator<=(const_iterator other) const
const T * operator->() const
constexpr bool operator>=(const_iterator other) const
constexpr bool operator>(iterator other) const
iterator operator+(qsizetype j) const
iterator & operator-=(qsizetype j)
T & operator[](qsizetype j) const
constexpr bool operator<(const_iterator other) const
constexpr bool operator!=(pointer p) const
constexpr bool operator<=(iterator other) const
qsizetype difference_type
constexpr bool operator!=(iterator o) const
constexpr bool operator<=(const_iterator other) const
constexpr bool operator>(const_iterator other) const
constexpr bool operator>=(iterator other) const
constexpr bool operator<(iterator other) const
friend iterator operator+(qsizetype j, iterator k)
std::random_access_iterator_tag iterator_category
constexpr bool operator!=(const_iterator o) const
constexpr bool operator==(const_iterator o) const
constexpr bool operator>=(const_iterator other) const
qsizetype operator-(iterator j) const
constexpr iterator()=default
iterator operator-(qsizetype j) const
constexpr bool operator==(iterator o) const
iterator & operator+=(qsizetype j)
constexpr bool operator==(pointer p) const
void append(const_iterator i1, const_iterator i2)
iterator insert(const_iterator before, parameter_type t)
qsizetype size() const noexcept
void removeFirst() noexcept
QList< T > & fill(parameter_type t, qsizetype size=-1)
const_pointer constData() const noexcept
void push_front(rvalue_ref t)
bool isEmpty() const noexcept
typename std::conditional< DataPointer::pass_parameter_by_value, DisableRValueRefs, T && >::type rvalue_ref
void replace(qsizetype i, rvalue_ref t)
const_iterator begin() const noexcept
void push_back(rvalue_ref t)
bool isDetached() const noexcept
void removeAt(qsizetype i)
QList< T > last(qsizetype n) const
bool isSharedWith(const QList< T > &other) const
iterator insert(const_iterator before, rvalue_ref t)
QList< T > & operator+=(const QList< T > &l)
QList< T > operator+(const QList< T > &l) &&
reference emplaceFront(Args &&... args)
reference emplace_back(Args &&... args)
const T & constLast() const noexcept
iterator erase(const_iterator begin, const_iterator end)
void resizeForOverwrite(qsizetype size)
QList< T > sliced(qsizetype pos, qsizetype n) const
QList(std::initializer_list< T > args)
QTypeTraits::compare_eq_result_container< QList, U > operator==(const QList &other) const
iterator insert(qsizetype i, parameter_type t)
QTypeTraits::compare_lt_result_container< QList, U > operator<=(const QList &other) const noexcept(noexcept(other< std::declval< QList< U > >()))
bool empty() const noexcept
bool removeOne(const AT &t)
QList< T > toList() const noexcept
QList(InputIterator i1, InputIterator i2)
QList< T > & operator+=(rvalue_ref t)
static QList< T > fromReadOnlyData(const T(&t)[N]) noexcept
static QList< T > fromList(const QList< T > &list) noexcept
QList(qsizetype size, parameter_type t)
const_reference back() const noexcept
qsizetype capacity() const
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())))
void swapItemsAt(qsizetype i, qsizetype j)
void push_back(parameter_type t)
QList< T > operator+(const QList< T > &l) const &
const_iterator end() const noexcept
iterator erase(const_iterator pos)
bool endsWith(parameter_type t) const
qsizetype count(const AT &t) const noexcept
bool startsWith(parameter_type t) const
friend qsizetype QtPrivate::lastIndexOf(const QList< V > &list, const U &u, qsizetype from) noexcept
QList(qsizetype size, Qt::Initialization)
QList< T > operator+(QList< T > &&l) &&
typename DataPointer::parameter_type parameter_type
qsizetype length() const noexcept
std::reverse_iterator< iterator > reverse_iterator
const_reference at(qsizetype i) const noexcept
iterator insert(qsizetype i, rvalue_ref t)
QList< T > & operator<<(parameter_type t)
QList< T > sliced(qsizetype pos) const
QList< T > toVector() const noexcept
T value(qsizetype i) const
void prepend(parameter_type t)
void swap(QList &other) noexcept
iterator insert(const_iterator before, qsizetype n, parameter_type t)
QList< T > & operator=(std::initializer_list< T > args)
void move(qsizetype from, qsizetype to)
QList(DataPointer dd) noexcept
const_reverse_iterator crbegin() const noexcept
reference operator[](qsizetype i)
void append(rvalue_ref t)
const_iterator constBegin() const noexcept
static qsizetype max_size() noexcept
const_reference operator[](qsizetype i) const noexcept
const_reverse_iterator rbegin() const noexcept
void remove(qsizetype i, qsizetype n=1)
qsizetype removeIf(Predicate pred)
std::reverse_iterator< const_iterator > const_reverse_iterator
qsizetype removeAll(const AT &t)
iterator emplace(qsizetype i, Args &&... args)
const T & first() const noexcept
iterator insert(qsizetype i, qsizetype n, parameter_type t)
void push_front(parameter_type t)
void append(QList< T > &&l)
qsizetype count() const noexcept
reference emplaceBack(Args &&... args)
QList< T > mid(qsizetype pos, qsizetype len=-1) const
QTypeTraits::compare_lt_result_container< QList, U > operator>(const QList &other) const noexcept(noexcept(other< std::declval< QList< U > >()))
void prepend(rvalue_ref t)
QList< T > operator+(QList< T > &&l) const &
QList & assign(std::initializer_list< T > l)
void resize(qsizetype size, parameter_type c)
QList< T > first(qsizetype n) const
const T & constFirst() const noexcept
iterator emplace(const_iterator before, Args &&... args)
void reserve(qsizetype size)
QList & assign(InputIterator first, InputIterator last)
static QList< T > fromVector(const QList< T > &vector) noexcept
void replace(qsizetype i, parameter_type t)
reverse_iterator rbegin()
void pop_front() noexcept
const T & const_reference
const T & last() const noexcept
void removeLast() noexcept
void resize(qsizetype size)
const_iterator cend() const noexcept
void append(parameter_type t)
QList< T > & operator+=(parameter_type t)
QTypeTraits::compare_eq_result_container< QList, U > operator!=(const QList &other) const
const_iterator constEnd() const noexcept
const_reverse_iterator rend() const noexcept
T value(qsizetype i, parameter_type defaultValue) const
const_iterator cbegin() const noexcept
QList & assign(qsizetype n, parameter_type t)
QTypeTraits::compare_lt_result_container< QList, U > operator>=(const QList &other) const noexcept(noexcept(std::declval< QList< U > >()< other))
const_pointer data() const noexcept
const_reference front() const noexcept
QList< T > & operator+=(QList< T > &&l)
friend qsizetype QtPrivate::indexOf(const QList< V > &list, const U &u, qsizetype from) noexcept
void append(const QList< T > &l)
const_reverse_iterator crend() const noexcept
QList< uint > toUcs4() const
Returns a UCS-4/UTF-32 representation of the string view as a QList<uint>.
\macro QT_RESTRICTED_CAST_FROM_ASCII
list append(new Employee("Blackpool", "Stephen"))
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
std::enable_if_t< std::conjunction_v< QTypeTraits::has_operator_less_than_container< Container, T >... >, bool > compare_lt_result_container
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype lastIndexOf(QByteArrayView haystack, qsizetype from, char needle) noexcept
auto sequential_erase_one(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
Q_CORE_EXPORT QList< uint > convertToUcs4(QStringView str)
auto sequential_erase_if(Container &c, Predicate &pred)
auto sequential_erase_with_copy(Container &c, const T &t)
auto sequential_erase(Container &c, const T &t)
qsizetype indexOf(const QList< V > &list, const U &u, qsizetype from) noexcept
static jboolean copy(JNIEnv *, jobject)
qsizetype erase_if(QByteArray &ba, Predicate pred)
qsizetype erase(QByteArray &ba, const T &t)
size_t qHash(const QFileSystemWatcherPathKey &key, size_t seed=0)
size_t qHashRange(InputIterator first, InputIterator last, size_t seed=0) noexcept(noexcept(qHash(*first)))
#define Q_DECLARE_SEQUENTIAL_ITERATOR(C)
#define Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(C)
QList(InputIterator, InputIterator) -> QList< ValueType >
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei GLsizei GLfloat distance
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
#define Q_ASSERT_X(cond, x, msg)
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
QT_BEGIN_NAMESPACE constexpr void qSwap(T &value1, T &value2) noexcept(std::is_nothrow_swappable_v< T >)
#define QT_DEPRECATED_VERSION_X_6_3(text)
settings remove("monkey")
void detach(QArrayDataPointer *old=nullptr)
std::conditional< pass_parameter_by_value, T, constT & >::type parameter_type
@ pass_parameter_by_value
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept
const Self * self() const
~QListSpecialMethodsBase()=default
bool contains(const AT &t) const noexcept
qsizetype lastIndexOf(const AT &t, qsizetype from=-1) const noexcept
~QListSpecialMethods()=default