44 #include <QtCore/qarraydatapointer.h>
45 #include <QtCore/qnamespace.h>
46 #include <QtCore/qhashfunctions.h>
47 #include <QtCore/qiterator.h>
48 #include <QtCore/qcontainertools_impl.h>
52 #include <initializer_list>
53 #include <type_traits>
68 Self *
self() {
return static_cast<Self *
>(
this); }
69 const Self *
self()
const {
return static_cast<const Self *
>(
this); }
72 template <
typename AT = T>
74 template <typename
AT =
T>
77 template <typename
AT =
T>
95 #if !defined(QT_STRICT_QLIST_ITERATORS) && (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)) && !defined(Q_OS_WIN)
96 #define QT_STRICT_QLIST_ITERATORS
100 template<
typename T>
class QVector :
public QList<T> {};
103 template <
typename T>
112 class DisableRValueRefs {};
141 #ifdef QT_STRICT_QLIST_ITERATORS
149 #if __cplusplus >= 202002L && (!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE >= 11)
150 using iterator_concept = std::contiguous_iterator_tag;
158 #ifndef QT_STRICT_QLIST_ITERATORS
183 #if QT_DEPRECATED_SINCE(6, 3) && !defined(QT_STRICT_QLIST_ITERATORS)
185 "the implicit conversion between a QList/QVector::iterator "
187 inline operator
T*()
const {
return i; }
189 template <
typename Int> std::enable_if_t<std::is_integral_v<Int>,
iterator>
191 template <
typename Int> std::enable_if_t<std::is_integral_v<Int>,
iterator>
193 template <
typename Int> std::enable_if_t<std::is_integral_v<Int>,
iterator>
195 template <
typename Int> std::enable_if_t<std::is_integral_v<Int>,
iterator>
197 template <
typename Int>
friend std::enable_if_t<std::is_integral_v<Int>,
iterator>
211 const T *
i =
nullptr;
212 #ifdef QT_STRICT_QLIST_ITERATORS
220 #if __cplusplus >= 202002L && (!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE >= 11)
221 using iterator_concept = std::contiguous_iterator_tag;
229 #ifndef QT_STRICT_QLIST_ITERATORS
255 #if QT_DEPRECATED_SINCE(6, 3) && !defined(QT_STRICT_QLIST_ITERATORS)
257 "the implicit conversion between a QList/QVector::const_iterator "
261 template <
typename Int> std::enable_if_t<std::is_integral_v<Int>,
const_iterator>
263 template <
typename Int> std::enable_if_t<std::is_integral_v<Int>,
const_iterator>
265 template <
typename Int> std::enable_if_t<std::is_integral_v<Int>,
const_iterator>
267 template <
typename Int> std::enable_if_t<std::is_integral_v<Int>,
const_iterator>
269 template <
typename Int>
friend std::enable_if_t<std::is_integral_v<Int>,
const_iterator>
288 const std::less<const T*> less = {};
289 return !less(
d->end(),
i.i) && !less(
i.i,
d->begin());
303 d->appendInitialize(
size);
326 template <
typename InputIterator, QtPrivate::IfIsInputIterator<InputIterator> = true>
327 QList(InputIterator i1, InputIterator i2)
329 if constexpr (!std::is_convertible_v<
typename std::iterator_traits<InputIterator>::iterator_category, std::forward_iterator_tag>) {
330 std::copy(i1, i2, std::back_inserter(*
this));
337 if constexpr (std::is_same_v<std::decay_t<InputIterator>,
iterator> ||
339 d->copyAppend(i1.i, i2.i);
341 d->appendIteratorRange(i1, i2);
348 template<
typename String,
typename = std::enable_if_t<std::is_same_v<T, QString> && std::is_convertible_v<String, QString>>>
357 template <
typename U = T>
368 template <
typename U = T>
371 return !(*
this ==
other);
374 template <
typename U = T>
381 return std::lexicographical_compare(
begin(),
end(),
385 template <
typename U = T>
389 return other < *
this;
392 template <
typename U = T>
396 return !(
other < *
this);
399 template <
typename U = T>
403 return !(*
this <
other);
422 resize_internal(
size);
428 resize_internal(
size);
448 if (
d->needsDetach()) {
459 Q_ASSERT_X(
size_t(
i) <
size_t(
d->size),
"QList::at",
"index out of range");
464 Q_ASSERT_X(
size_t(
i) <
size_t(
d->size),
"QList::operator[]",
"index out of range");
481 append(
l.constBegin(),
l.constEnd());
493 template<
typename...
Args>
496 template <
typename ...Args>
504 Q_ASSERT_X(isValidIterator(before),
"QList::insert",
"The specified iterator argument 'before' is invalid");
509 Q_ASSERT_X(isValidIterator(before),
"QList::insert",
"The specified iterator argument 'before' is invalid");
514 Q_ASSERT_X(isValidIterator(before),
"QList::insert",
"The specified iterator argument 'before' is invalid");
527 template <
typename ...Args>
530 Q_ASSERT_X(isValidIterator(before),
"QList::emplace",
"The specified iterator argument 'before' is invalid");
534 template <
typename ...Args>
537 template<
class InputIt >
543 Q_ASSERT_X(
i >= 0 && i < d->
size,
"QList<T>::replace",
"index out of range");
554 Q_ASSERT_X(
i >= 0 && i < d->
size,
"QList<T>::replace",
"index out of range");
557 d.data()[
i] = std::move(
t);
574 template <
typename AT>
576 template <typename
AT>
578 template <typename
AT>
582 template <
typename AT = T>
589 template <
typename AT = T>
595 template <
typename AT = T>
601 template <
typename Predicate>
610 Q_ASSERT_X(from >= 0 && from <
size(),
"QList::move(qsizetype, qsizetype)",
"'from' is out-of-range");
611 Q_ASSERT_X(to >= 0 && to <
size(),
"QList::move(qsizetype, qsizetype)",
"'to' is out-of-range");
615 T *
const b =
d->begin();
681 "QList<T>::swap",
"index out of range");
694 template <
typename ...Args>
698 {
return d->size == 0; }
711 {
QList n = *
this;
n += std::move(
l);
return n; }
717 { *
this +=
l;
return *
this; }
719 { *
this += std::move(
l);
return *
this; }
721 {
append(std::move(
t));
return *
this; }
723 {
append(std::move(
t));
return *
this; }
732 template<qsizetype N>
735 return QList<T>({
nullptr,
const_cast<T *
>(
t),
N });
739 template <
typename InputIterator,
744 template <
typename T>
749 if (
d->needsDetach() || newSize > capacity() -
d.freeSpaceAtBegin()) {
751 }
else if (newSize <
size()) {
752 d->truncate(newSize);
756 template <
typename T>
760 if (asize <= capacity() -
d.freeSpaceAtBegin()) {
761 if (
d->flags() & Data::CapacityReserved)
763 if (!
d->isShared()) {
765 d->setFlag(Data::CapacityReserved);
773 detached->setFlag(Data::CapacityReserved);
777 template <
typename T>
782 if (
d->needsDetach() ||
size() < capacity()) {
794 d->clearFlag(Data::CapacityReserved);
797 template <
typename T>
800 Q_ASSERT_X(
size_t(
i) +
size_t(
n) <=
size_t(
d->size),
"QList::remove",
"index out of range");
801 Q_ASSERT_X(
n >= 0,
"QList::remove",
"invalid count");
807 d->erase(
d->begin() +
i,
n);
810 template <
typename T>
818 template <
typename T>
830 return size_t(
i) < size_t(
d->size) ?
at(
i) : defaultValue;
833 template <
typename T>
836 d->growAppend(i1.i, i2.i);
839 template <
typename T>
845 if (
other.d->needsDetach() || !std::is_nothrow_move_constructible_v<T>)
855 template<
typename...
Args>
858 d->emplace(0, std::forward<Args>(
args)...);
863 template <
typename T>
867 Q_ASSERT_X(
size_t(
i) <=
size_t(
d->size),
"QList<T>::insert",
"index out of range");
868 Q_ASSERT_X(
n >= 0,
"QList::insert",
"invalid count");
874 template <
typename T>
875 template <
typename ...Args>
879 Q_ASSERT_X(
i >= 0 && i <= d->
size,
"QList<T>::insert",
"index out of range");
880 d->emplace(
i, std::forward<Args>(
args)...);
885 template<
typename...
Args>
888 d->emplace(
d->size, std::forward<Args>(
args)...);
892 template <
typename T>
895 Q_ASSERT_X(isValidIterator(abegin),
"QList::erase",
"The specified iterator argument 'abegin' is invalid");
896 Q_ASSERT_X(isValidIterator(aend),
"QList::erase",
"The specified iterator argument 'aend' is invalid");
906 template <
typename T>
911 if (
d->needsDetach() || newSize > capacity()) {
919 d->assign(
d.begin(),
d.begin() + qMin(
size(), newSize),
t);
920 if (newSize >
size()) {
921 d->copyAppend(newSize -
size(), copy);
922 }
else if (newSize <
size()) {
923 d->truncate(newSize);
930 template <
typename T,
typename U>
945 template <
typename T,
typename U>
964 template <
typename T>
965 template <
typename AT>
971 template <
typename T>
972 template <
typename AT>
978 template <
typename T>
1003 template <
typename T>
1010 template <
typename T,
typename AT>
1016 template <
typename T,
typename Predicate>
1027 #include <QtCore/qbytearraylist.h>
1028 #include <QtCore/qstringlist.h>
small capitals from c petite p scientific f u
small capitals from c petite p scientific i
[1]
The QByteArray class provides an array of bytes.
template< typename T > qsizetype erase(QByteArray &ba, const T &t)
template< typename Predicate > qsizetype erase_if(QByteArray &ba, Predicate pred)
template< typename Enum > size_t qHash(QFlags< Enum > flags, size_t seed=0) noexcept
template< typename InputIterator > size_t qHashRange(InputIterator first, InputIterator last, size_t seed=0)
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
const T & operator[](qsizetype j) const
const_iterator & operator-=(qsizetype j)
constexpr bool operator>(const_iterator other) const
std::random_access_iterator_tag iterator_category
constexpr const_iterator(iterator o)
constexpr const_iterator()=default
const_iterator & operator++()
constexpr bool operator!=(const_iterator o) const
const_iterator operator+(qsizetype j) const
const_iterator & operator+=(qsizetype j)
qsizetype difference_type
constexpr bool operator<=(iterator other) const
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++(int)
const T * operator->() const
const_iterator & operator--()
constexpr bool operator!=(iterator o) const
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
constexpr bool operator<(const_iterator other) const
constexpr bool operator!=(pointer p) const
constexpr bool operator<=(iterator other) const
qsizetype difference_type
T & operator[](qsizetype j) const
constexpr bool operator!=(iterator o) const
constexpr bool operator<=(const_iterator other) const
constexpr bool operator>(const_iterator other) const
iterator & operator+=(qsizetype j)
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
iterator & operator-=(qsizetype j)
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
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)
const T & last() const noexcept
bool isDetached() const noexcept
void removeAt(qsizetype i)
QTypeTraits::compare_lt_result_container< QList, U > operator>=(const QList &other) const noexcept(noexcept(std::declval< QList< U >>()< other))
bool isSharedWith(const QList< T > &other) const
iterator insert(const_iterator before, rvalue_ref t)
QList< T > & operator+=(parameter_type t)
reference emplaceFront(Args &&... args)
reference emplace_back(Args &&... args)
iterator erase(const_iterator begin, const_iterator end)
QList(std::initializer_list< T > args)
iterator insert(qsizetype i, parameter_type t)
bool empty() const noexcept
bool removeOne(const AT &t)
QList(InputIterator i1, InputIterator i2)
QList(qsizetype size, parameter_type t)
const_reference back() const noexcept
qsizetype capacity() const
void swapItemsAt(qsizetype i, qsizetype j)
void push_back(parameter_type t)
const_iterator end() const noexcept
iterator erase(const_iterator pos)
const T & constFirst() const noexcept
bool endsWith(parameter_type t) const
qsizetype count(const AT &t) const noexcept
bool startsWith(parameter_type t) const
QList< T > last(qsizetype n) const
QList< T > sliced(qsizetype pos) const
QTypeTraits::compare_eq_result_container< QList, U > operator!=(const QList &other) const
static QList< T > fromVector(const QList< T > &vector) noexcept
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)
T value(qsizetype i) const
void prepend(parameter_type t)
QList< T > first(qsizetype n) const
void swap(QList &other) noexcept
iterator insert(const_iterator before, qsizetype n, parameter_type t)
static QList< T > fromList(const QList< T > &list) noexcept
QList< T > & operator+=(QList< T > &&l)
void move(qsizetype from, qsizetype to)
QList(DataPointer dd) noexcept
QList< T > & operator=(std::initializer_list< T > args)
const_reverse_iterator crbegin() const noexcept
reference operator[](qsizetype i)
void append(rvalue_ref t)
const_iterator constBegin() const 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)
QList< T > sliced(qsizetype pos, qsizetype n) const
iterator emplace(qsizetype i, Args &&... args)
QList< T > operator+(QList< T > &&l) const
iterator insert(qsizetype i, qsizetype n, parameter_type t)
void push_front(parameter_type t)
QList< T > & operator+=(rvalue_ref t)
void append(QList< T > &&l)
qsizetype count() const noexcept
reference emplaceBack(Args &&... args)
QTypeTraits::compare_eq_result_container< QList, U > operator==(const QList &other) const
QList< T > mid(qsizetype pos, qsizetype len=-1) const
void prepend(rvalue_ref t)
void resize(qsizetype size, parameter_type c)
QTypeTraits::compare_lt_result_container< QList, U > operator<=(const QList &other) const noexcept(noexcept(other< std::declval< QList< U >>()))
iterator emplace(const_iterator before, Args &&... args)
void reserve(qsizetype size)
void replace(qsizetype i, parameter_type t)
QList< T > operator+(const QList< T > &l) const
reverse_iterator rbegin()
void pop_front() noexcept
QTypeTraits::compare_lt_result_container< QList, U > operator>(const QList &other) const noexcept(noexcept(other< std::declval< QList< U >>()))
const T & constLast() const noexcept
void removeLast() noexcept
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 resize(qsizetype size)
static QList< T > fromReadOnlyData(const T(&t)[N]) noexcept
const_iterator cend() const noexcept
void append(parameter_type t)
QList< T > toVector() const noexcept
const_iterator constEnd() const noexcept
const T & first() const noexcept
const_reverse_iterator rend() const noexcept
T value(qsizetype i, parameter_type defaultValue) const
const_iterator cbegin() const noexcept
const_pointer data() const noexcept
const_reference front() const noexcept
QList< T > & operator<<(parameter_type t)
void append(const QList< T > &l)
QList< T > toList() const noexcept
QList< T > & operator+=(const QList< T > &l)
const_reverse_iterator crend() const noexcept
The QString class provides a Unicode character string.
QList< uint > toUcs4() const
list append(new Employee("Blackpool", "Stephen"))
auto it unsigned count const
Generic::PredicateMatcher< T > Predicate(std::function< bool(T const &)> const &predicate, std::string const &description="")
typename C::value_type value_type
typename C::const_iterator const_iterator
typename C::iterator iterator
const PluginKeyMapConstIterator cend
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 QList< uint > convertToUcs4(QStringView str)
auto sequential_erase_one(Container &c, const T &t)
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
decltype(auto) cbegin(const T &t)
int distance(TestIterator &a, TestIterator &b)
#define QT_DEPRECATED_VERSION_X_6_3(text)
#define Q_DECLARE_SEQUENTIAL_ITERATOR(C)
#define Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(C)
QList(InputIterator, InputIterator) -> QList< ValueType >
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei count
GLsizei GLsizei GLfloat distance
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
#define Q_ASSERT_X(cond, x, msg)
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
settings remove("monkey")
rect rect item rotate(45)
[5]
@ pass_parameter_by_value
std::conditional< pass_parameter_by_value, T, const T & >::type parameter_type
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept
~QListSpecialMethodsBase()=default
bool contains(const AT &t) const noexcept
qsizetype lastIndexOf(const AT &t, qsizetype from=-1) const noexcept
~QListSpecialMethods()=default
static QPair< QTypedArrayData *, T * > allocate(qsizetype capacity, AllocationOption option=QArrayData::KeepSize)
static constexpr CutResult mid(qsizetype originalLength, qsizetype *_position, qsizetype *_length)
void appendInitialize(qsizetype newSize)
void copyAppend(const T *b, const T *e)
ByteArray detached(ByteArray b)