|
Qx v0.7.2
Qt Extensions Library
|
The FixedList template class is a compile-time friendly fixed size container that wraps std::array, but provides an API that better matches Qt's sequential containers (e.g. QList).
More...
#include <qx/core/qx-fixedlist.h>
Public Types | |
| using | const_iterator = typename std::array<T, N>::const_iterator |
| using | const_pointer = const T* |
| using | const_reference = const T& |
| using | const_reverse_iterator = typename std::array<T, N>::const_reverse_iterator |
| using | ConstIterator = const_iterator |
| using | difference_type = qsizetype |
| using | Iterator = iterator |
| using | iterator = typename std::array<T, N>::iterator |
| using | parameter_type = const T& |
| using | pointer = T* |
| using | reference = T& |
| using | reverse_iterator = typename std::array<T, N>::reverse_iterator |
| using | size_type = qsizetype |
| using | value_type = T |
Public Member Functions | |
| constexpr | FixedList ()=default |
| template<typename A> requires std::same_as<std::remove_cvref_t<A>, std::array<T, N>> | |
| constexpr | FixedList (A &&arr) |
| template<typename... Args> requires (N > 0 && sizeof...(Args) == N && (std::convertible_to<Args, T> && ...)) | |
| constexpr | FixedList (Args &&... args) |
| template<size_t M> requires (M == N) | |
| constexpr | FixedList (const T(&arr)[M]) |
| constexpr reference | at (qsizetype i) |
| constexpr const_reference | at (qsizetype i) const |
| constexpr reference | back () |
| constexpr const_reference | back () const |
| constexpr const_iterator | begin () const noexcept |
| constexpr iterator | begin () noexcept |
| constexpr const_iterator | cbegin () const noexcept |
| constexpr const_iterator | cend () const noexcept |
| template<qsizetype K> | |
| constexpr auto | chopped () const |
| constexpr const_iterator | constBegin () const noexcept |
| constexpr const_pointer | constData () const noexcept |
| constexpr const_iterator | constEnd () const noexcept |
| constexpr const_reference | constFirst () const |
| constexpr const_reference | constLast () const |
| template<typename AT = T> | |
| constexpr bool | contains (const AT &t) const |
| template<typename AT = T> | |
| constexpr qsizetype | count (const AT &t) const |
| constexpr const_reverse_iterator | crbegin () const noexcept |
| constexpr const_reverse_iterator | crend () const noexcept |
| constexpr const_pointer | data () const noexcept |
| constexpr pointer | data () noexcept |
| constexpr const_iterator | end () const noexcept |
| constexpr iterator | end () noexcept |
| template<typename AT = T> | |
| constexpr bool | endsWith (const AT &t) const |
| template<typename AT = T> | |
| constexpr FixedList & | fill (const AT &t) |
| constexpr reference | first () |
| constexpr const_reference | first () const |
| template<qsizetype K> | |
| constexpr auto | first () const |
| constexpr reference | front () |
| constexpr const_reference | front () const |
| template<size_t I> | |
| constexpr T && | get () &&noexcept |
| template<size_t I> | |
| constexpr T & | get () &noexcept |
| template<size_t I> | |
| constexpr const T & | get () const &noexcept |
| template<typename AT = T> | |
| constexpr qsizetype | indexOf (const AT &t, qsizetype from=0) const |
| constexpr reference | last () |
| constexpr const_reference | last () const |
| template<qsizetype K> | |
| constexpr auto | last () const |
| template<typename AT = T> | |
| constexpr qsizetype | lastIndexOf (const AT &t, qsizetype from=-1) const |
| template<qsizetype Pos, qsizetype Len = -1> | |
| constexpr auto | mid () const |
| constexpr void | move (qsizetype from, qsizetype to) |
| template<size_t M> | |
| constexpr FixedList< T, N+M > | operator+ (const FixedList< T, M > &other) const |
| constexpr FixedList< T, N+1 > | operator+ (const T &other) const |
| template<size_t M> | |
| constexpr FixedList< T, N+M > | operator+ (const T(&other)[M]) const |
| constexpr auto | operator<=> (const FixedList &other) const =default |
| constexpr bool | operator== (const FixedList &other) const =default |
| constexpr reference | operator[] (qsizetype i) |
| constexpr const_reference | operator[] (qsizetype i) const |
| constexpr const_reverse_iterator | rbegin () const noexcept |
| constexpr reverse_iterator | rbegin () noexcept |
| constexpr const_reverse_iterator | rend () const noexcept |
| constexpr reverse_iterator | rend () noexcept |
| template<typename AT = T> | |
| constexpr void | replace (qsizetype i, const AT &t) |
| template<qsizetype Pos, qsizetype K> | |
| constexpr auto | sliced () const |
| template<qsizetype Pos> | |
| constexpr auto | sliced () const |
| template<typename AT = T> | |
| constexpr bool | startsWith (const AT &t) const |
| constexpr const std::array< T, N > & | stdArray () const noexcept |
| constexpr std::array< T, N > & | stdArray () noexcept |
| constexpr void | swap (FixedList &other) noexcept(std::is_nothrow_swappable_v< T >) |
| constexpr void | swapItemsAt (qsizetype i, qsizetype j) |
| QList< T > | toList () const |
| constexpr std::array< T, N > | toStdArray () const |
| constexpr T | value (qsizetype i) const |
| template<typename AT = T> | |
| constexpr T | value (qsizetype i, const AT &defaultValue) const |
Static Public Member Functions | |
| static constexpr qsizetype | count () noexcept |
| static constexpr bool | empty () noexcept |
| static constexpr bool | isEmpty () noexcept |
| static constexpr qsizetype | length () noexcept |
| static constexpr qsizetype | size () noexcept |
Static Public Attributes | |
| static constexpr qsizetype | size_v = static_cast<qsizetype>(N) |
Friends | |
| size_t | qHash (const FixedList &key, size_t seed=0) |
| constexpr void | swap (FixedList &a, FixedList &b) noexcept(noexcept(a.swap(b))) |
Related Symbols | |
(Note that these are not member symbols.) | |
| template<typename T, size_t N> | |
| constexpr FixedList< T, N > | makeFixedList (const T(&arr)[N]) |
| template<typename T, size_t N> | |
| constexpr FixedList< T, 1+N > | operator+ (const std::type_identity_t< T > &a, const FixedList< T, N > &b) |
| template<typename T, size_t M, size_t N> | |
| constexpr FixedList< T, M+N > | operator+ (const T(&a)[M], const FixedList< T, N > &b) |
The underlying iterators are those of std::array, so a FixedList can be used with all of the standard algorithms (i.e. std::sort(), std::ranges::reverse(), etc.), many of which are usable in constant expressions.
Both the element type and size can be deduced when constructing from a C array or from a series of elements:.
FixedList<int>{{1,2,3}}). Use makeFixedList() if you wish to explicitly specify the element type but still have the size deduced.A FixedList can also be used with structured bindings.
| using Qx::FixedList< T, N >::const_iterator = typename std::array<T, N>::const_iterator |
| using Qx::FixedList< T, N >::const_pointer = const T* |
A pointer to a constant item in the list (const T*).
| using Qx::FixedList< T, N >::const_reference = const T& |
A reference to a constant item in the list (const T&).
| using Qx::FixedList< T, N >::const_reverse_iterator = typename std::array<T, N>::const_reverse_iterator |
| using Qx::FixedList< T, N >::ConstIterator = const_iterator |
Qt-style synonym for FixedList::const_iterator.
| using Qx::FixedList< T, N >::difference_type = qsizetype |
The type used for the difference between positions in the list (qsizetype).
| using Qx::FixedList< T, N >::Iterator = iterator |
Qt-style synonym for FixedList::iterator.
| using Qx::FixedList< T, N >::iterator = typename std::array<T, N>::iterator |
| using Qx::FixedList< T, N >::parameter_type = const T& |
The type used when passing an item to a function (const T&).
| using Qx::FixedList< T, N >::pointer = T* |
A pointer to an item in the list (T*).
| using Qx::FixedList< T, N >::reference = T& |
A reference to an item in the list (T&).
| using Qx::FixedList< T, N >::reverse_iterator = typename std::array<T, N>::reverse_iterator |
| using Qx::FixedList< T, N >::size_type = qsizetype |
The type used for sizes and counts (qsizetype).
| using Qx::FixedList< T, N >::value_type = T |
The type of the items stored in the list (T).
|
constexprdefault |
Constructs an empty list.
|
inlineconstexpr |
Constructs a list that contains copies of the items in the C array arr.
Requires that M is equal to N.
|
inlineconstexpr |
Constructs a list that contains the items in the std::array arr, which are copied or moved depending on the value category of arr.
Requires that A is a (possibly cv-qualified/reference) std::array<T, N>.
|
inlineconstexpr |
Constructs a list from the items in args, each of which must be convertible to T.
Requires that the number of arguments is equal to N, and that N is greater than zero. This constructor is explicit if N is 1.
|
inlineconstexpr |
Returns the item at index position i as a modifiable reference.
i must be a valid index position in the list (i.e., 0 <= i < size()).
|
inlineconstexpr |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineconstexpr |
This function is provided for STL compatibility. It is equivalent to last().
|
inlineconstexpr |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineconstexprnoexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineconstexprnoexcept |
Returns an STL-style iterator pointing to the first item in the list.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexpr |
|
inlineconstexprnoexcept |
Returns a const STL-style iterator pointing to the first item in the list.
|
inlineconstexprnoexcept |
Returns a const pointer to the data stored in the list.
|
inlineconstexprnoexcept |
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list.
|
inlineconstexpr |
Returns a const reference to the first item in the list.
Requires the list to not be empty.
|
inlineconstexpr |
Returns a const reference to the last item in the list.
Requires the list to not be empty.
|
inlineconstexpr |
Returns true if the list contains an item equal to t; otherwise, returns false.
This function requires AT to be comparable with T via operator==().
|
inlinestaticconstexprnoexcept |
|
inlineconstexpr |
Returns the number of items in the list that are equal to t.
This function requires AT to be comparable with T via operator==().
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineconstexprnoexcept |
Returns a pointer to the data stored in the list. The pointer can be used to access and modify the items in the list.
The pointer remains valid for as long as the list exists.
|
inlinestaticconstexprnoexcept |
This function is provided for STL compatibility. It is equivalent to isEmpty().
|
inlineconstexprnoexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineconstexprnoexcept |
Returns an STL-style iterator pointing to the imaginary item after the last item in the list.
|
inlineconstexpr |
Returns true if the list is not empty and its last item is equal to t; otherwise, returns false.
This function requires AT to be comparable with T via operator==().
|
inlineconstexpr |
Assigns t to all items in the list. Returns a reference to the list.
This function requires T to be assignable from AT.
|
inlineconstexpr |
Returns a reference to the first item in the list.
Requires the list to not be empty.
|
inlineconstexpr |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineconstexpr |
|
inlineconstexpr |
This function is provided for STL compatibility. It is equivalent to first().
|
inlineconstexpr |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineconstexprnoexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineconstexprnoexcept |
Returns a reference to the item at index I.
This function exists to provide support for structured bindings. I must be less than N.
|
inlineconstexprnoexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineconstexpr |
Returns the index position of the first occurrence of t in the list, searching forward from index position from. Returns -1 if no item matched.
If from is negative, it is interpreted as an offset from the end of the list (i.e. -1 starts the search at the last item).
This function requires AT to be comparable with T via operator==().
|
inlinestaticconstexprnoexcept |
Returns true if the list has a size of 0; otherwise, returns false.
|
inlineconstexpr |
Returns a reference to the last item in the list.
Requires the list to not be empty.
|
inlineconstexpr |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineconstexpr |
|
inlineconstexpr |
Returns the index position of the last occurrence of t in the list, searching backward from index position from. Returns -1 if no item matched.
If from is negative, it is interpreted as an offset from the end of the list (i.e. -1, the default, starts the search at the last item). If from is greater than or equal to the size of the list, the search starts at the last item.
This function requires AT to be comparable with T via operator==().
|
inlinestaticconstexprnoexcept |
|
inlineconstexpr |
Returns a FixedList that contains copies of up to Len items in this list, starting at index position Pos.
If Len is negative (the default) or would extend past the end of the list, all items from Pos to the end are returned. The size of the result is therefore min(Len, N - Pos), or N - Pos if Len is negative.
Unlike QList::mid(), Pos must be non-negative and no greater than N, as an out-of-range position would otherwise need to produce a differently sized list at run-time.
|
inlineconstexpr |
Moves the item at index position from to index position to, shifting the items in between accordingly.
Both from and to must be valid index positions in the list (i.e., 0 <= from, to < size()).
|
inlineconstexpr |
Returns a FixedList of size N + M that contains all the items in this list followed by all the items in other.
|
inlineconstexpr |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns a FixedList of size N + 1 that contains all the items in this list followed by other.
|
inlineconstexpr |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns a FixedList of size N + M that contains all the items in this list followed by all the items in the C array other.
|
constexprdefault |
Returns the ordering of other relative to this.
Items are compared lexicographically. This operator is only available if T supports three-way comparison or operator<(); otherwise it is deleted.
|
constexprdefault |
Returns true if the FixedList is equal to other; otherwise, returns false.
Two lists are equal if each of their items compare equal, in order. Lists of different sizes or different element types are different types and cannot be compared.
operator!=() is synthesized from this operator.
|
inlineconstexpr |
|
inlineconstexpr |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineconstexprnoexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineconstexprnoexcept |
|
inlineconstexpr |
Replaces the item at index position i with t.
i must be a valid index position in the list (i.e., 0 <= i < size()).
This function requires T to be assignable from AT.
|
inlinestaticconstexprnoexcept |
|
inlineconstexpr |
|
inlineconstexpr |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns a FixedList<T, N - Pos> that contains copies of all items in this list from index position Pos to the end.
Pos must be non-negative and no greater than N.
|
inlineconstexpr |
Returns true if the list is not empty and its first item is equal to t; otherwise, returns false.
This function requires AT to be comparable with T via operator==().
|
inlineconstexprnoexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineconstexprnoexcept |
Returns a reference to the underlying std::array.
|
inlineconstexprnoexcept |
Swaps the contents of this list with other.
|
inlineconstexpr |
|
inline |
Returns a QList that contains copies of the items in this list.
|
inlineconstexpr |
Returns a copy of the underlying std::array.
|
inlineconstexpr |
Returns the item at index position i in the list. If i is out of bounds, the function returns a default-constructed value.
Requires T to be default-initializable.
|
inlineconstexpr |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
If i is out of bounds, the function returns defaultValue converted to T.
|
Creates a FixedList from a C array or braced list, deducing the size. The element type can be explicitly specified when the deduced one isn't wanted, i.e. makeFixedList<double>({1, 2, 3}).
|
Returns a FixedList which is the result of concatenating a and b.
|
Returns a FixedList which is the result of concatenating a and b.
|
friend |
Returns the hash value for key, using seed to seed the calculation.
This function requires T to be hashable via qHash().
Swaps the contents of a and b.
|
staticconstexpr |
The number of items in the list.
For ease of use in some contexts at compile-time.