|
|
| List ()=default |
| | Default constructor. Creates an empty list.
|
| |
| | List (size_t size) |
| | Constructs a list with a given number of default-constructed elements.
|
| |
| | List (size_t size, const T &defaultValue) |
| | Constructs a list with a given number of copies of a value.
|
| |
|
| List (const List &other) |
| | Copy constructor.
|
| |
|
| List (List &&other) noexcept |
| | Move constructor.
|
| |
| | List (std::initializer_list< T > initList) |
| | Constructs a list from an initializer list.
|
| |
|
| ~List ()=default |
| | Destructor.
|
| |
|
List & | operator= (const List &other) |
| | Copy assignment operator.
|
| |
|
List & | operator= (List &&other) noexcept |
| | Move assignment operator.
|
| |
| List & | operator= (std::initializer_list< T > initList) |
| | Assigns from an initializer list, replacing all contents.
|
| |
| List & | operator+= (const T &item) |
| | Appends a single item to the back of the list.
|
| |
| List & | operator+= (T &&item) |
| | Appends a single item to the back of the list (move overload).
|
| |
| List & | operator+= (const List &list) |
| | Appends all items from another list to the back of this list.
|
| |
| List & | operator+= (List &&list) |
| | Appends all items from another list (move overload).
|
| |
|
Iterator | begin () noexcept |
| | Returns a mutable iterator to the first element.
|
| |
|
ConstIterator | begin () const noexcept |
| | Returns a const iterator to the first element.
|
| |
|
ConstIterator | cbegin () const noexcept |
| | Returns a const iterator to the first element.
|
| |
| ConstIterator | constBegin () const noexcept |
| | Returns a const iterator to the first element.
|
| |
|
RevIterator | rbegin () noexcept |
| | Returns a mutable reverse iterator to the last element.
|
| |
| RevIterator | revBegin () noexcept |
| | Returns a mutable reverse iterator to the last element.
|
| |
|
ConstRevIterator | crbegin () const noexcept |
| | Returns a const reverse iterator to the last element.
|
| |
| ConstRevIterator | constRevBegin () const noexcept |
| | Returns a const reverse iterator to the last element.
|
| |
|
Iterator | end () noexcept |
| | Returns a mutable iterator to one past the last element.
|
| |
|
ConstIterator | end () const noexcept |
| | Returns a const iterator to one past the last element.
|
| |
|
ConstIterator | cend () const noexcept |
| | Returns a const iterator to one past the last element.
|
| |
| ConstIterator | constEnd () const noexcept |
| | Returns a const iterator to one past the last element.
|
| |
|
RevIterator | rend () noexcept |
| | Returns a mutable reverse iterator to one before the first element.
|
| |
| RevIterator | revEnd () noexcept |
| | Returns a mutable reverse iterator to one before the first element.
|
| |
|
ConstRevIterator | crend () const noexcept |
| | Returns a const reverse iterator to one before the first element.
|
| |
| ConstRevIterator | constRevEnd () const noexcept |
| | Returns a const reverse iterator to one before the first element.
|
| |
| T & | at (size_t index) |
| | Returns a reference to the element at index with bounds checking.
|
| |
| const T & | at (size_t index) const |
| | Returns a reference to the element at index with bounds checking.
|
| |
| T & | operator[] (size_t index) |
| | Returns a reference to the element at index without bounds checking.
|
| |
| const T & | operator[] (size_t index) const |
| | Returns a reference to the element at index without bounds checking.
|
| |
|
T & | front () |
| | Returns a reference to the first element.
|
| |
| const T & | front () const |
| | Returns a reference to the first element.
|
| |
|
T & | back () |
| | Returns a reference to the last element.
|
| |
| const T & | back () const |
| | Returns a reference to the last element.
|
| |
|
T * | data () noexcept |
| | Returns a pointer to the underlying contiguous storage.
|
| |
| const T * | data () const noexcept |
| | Returns a pointer to the underlying contiguous storage.
|
| |
|
bool | isEmpty () const noexcept |
| | Returns true if the list has no elements.
|
| |
|
size_t | size () const noexcept |
| | Returns the number of elements in the list.
|
| |
|
size_t | maxSize () const noexcept |
| | Returns the maximum number of elements the list can theoretically hold.
|
| |
| void | reserve (size_t newCapacity) |
| | Pre-allocates storage for at least newCapacity elements.
|
| |
|
size_t | capacity () const noexcept |
| | Returns the number of elements the list can hold without reallocating.
|
| |
|
void | shrink () |
| | Releases unused memory by shrinking capacity to fit the current size.
|
| |
|
void | clear () noexcept |
| | Removes all elements from the list.
|
| |
| Iterator | insert (ConstIterator pos, const T &value) |
| | Inserts a value before the position given by an iterator.
|
| |
| Iterator | insert (ConstIterator pos, T &&value) |
| | Inserts a value before the position given by an iterator (move overload).
|
| |
| Iterator | insert (size_t pos, const T &value) |
| | Inserts a value before the given index.
|
| |
| Iterator | insert (size_t pos, T &&value) |
| | Inserts a value before the given index (move overload).
|
| |
| template<typename... Args> |
| Iterator | emplace (ConstIterator pos, Args &&...args) |
| | Emplaces an object right before the given position.
|
| |
| template<typename... Args> |
| Iterator | emplace (size_t pos, Args &&...args) |
| | Emplaces an object right before the given index.
|
| |
| Iterator | remove (ConstIterator pos) |
| | Removes the element at the given iterator position.
|
| |
| Iterator | erase (ConstIterator first, ConstIterator last) |
| | Removes elements in the range [first, last).
|
| |
| Iterator | remove (size_t index) |
| | Removes the element at the given index.
|
| |
| void | removeIf (TestFunc func) |
| | Runs a test function on all the items and removes them if it returns true.
|
| |
| bool | removeFirst (const T &value) |
| | Removes the first instance of value from the list.
|
| |
| void | pushToBack (const T &value) |
| | Pushes an item onto the back of the list.
|
| |
| void | pushToBack (const List< T > &list) |
| | Pushes all items from another list to the back of this list.
|
| |
| void | pushToBack (T &&value) |
| | Moves an item onto the back of the list.
|
| |
| void | pushToBack (List< T > &&list) |
| | Moves all items from another list to the back of this list.
|
| |
| template<typename... Args> |
| T & | emplaceToBack (Args &&...args) |
| | Emplaces an object on the back of the list.
|
| |
|
void | popFromBack () |
| | Removes the last element from the list.
|
| |
| void | resize (size_t newSize) |
| | Resizes the list.
|
| |
| void | resize (size_t newSize, const T &value) |
| | Resizes the list, constructs any new items with the given value.
|
| |
| void | swap (List< T > &other) noexcept |
| | Swaps the list data with another list of the same type.
|
| |
| bool | set (size_t index, const T &val) |
| | Sets an item in the list by index.
|
| |
| List< T > | sort () const |
| | Returns a sorted copy of this list.
|
| |
| List< T > | reverse () const |
| | Returns a reversed copy of this list.
|
| |
| List< T > | unique () |
| | Returns a list of all the unique items in this list.
|
| |
| template<typename Func > |
| void | forEach (Func &&func) const |
| | Calls func for every element.
|
| |
| bool | contains (const T &val) const |
| | Returns true if the list contains the given value.
|
| |
| ssize_t | indexOf (const T &value) const |
| | Returns the index of the first occurrence of value.
|
| |
| ssize_t | lastIndexOf (const T &value) const |
| | Returns the index of the last occurrence of value.
|
| |
| size_t | count (const T &value) const |
| | Returns the number of occurrences of value.
|
| |
| List< T > | mid (size_t pos, size_t length) const |
| | Returns a sublist starting at pos with length elements.
|
| |
template<typename T>
class List< T >
Dynamic array container wrapping std::vector.
Provides a Qt-inspired API over std::vector with consistent naming conventions matching the rest of libpromeki.
- Example
for(
int n :
nums) { ... }
Dynamic array container wrapping std::vector.
Definition list.h:40
void pushToBack(const T &value)
Pushes an item onto the back of the list.
Definition list.h:455
void removeIf(TestFunc func)
Runs a test function on all the items and removes them if it returns true.
Definition list.h:429
- Template Parameters
-