Luna::List
A container that stores elements as double-linked lists (nodes connected by pointers).
template <typename _Ty, typename _Alloc>
class Luna::List
Member functions
-
Constructs an empty list.
-
List(const allocator_type &alloc)
Constructs an empty list with an custom allocator.
-
List(usize count, const_reference value, const allocator_type &alloc=allocator_type())
Constructs a list with the specified number of elements.
-
List(usize count, const allocator_type &alloc=allocator_type())
Constructs a list with the specified number of elements. Elements will be default-initialized.
-
Constructs a list with elements specified by one range. Elements in the range will be copy-inserted into the list.
-
Constructs a list by copying elements from another list.
-
List(const List &rhs, const allocator_type &alloc)
Constructs a list with an custom allocator and with elements copied from another list.
-
Constructs a list by moving elements from another list.
-
List(List &&rhs, const allocator_type &alloc)
Constructs a list with an custom allocator and with elements moved from another list.
-
List(InitializerList< value_type > ilist, const allocator_type &alloc=allocator_type())
Constructs a list with elements specified by one initializer list.
-
List< _Ty, _Alloc > & operator=(const List &rhs)
Replaces elements of the list by coping elements from another list.
-
List< _Ty, _Alloc > & operator=(List &&rhs)
Replaces elements of the list by moving elements from another list.
-
List< _Ty, _Alloc > & operator=(InitializerList< value_type > ilist)
Replaces elements of the list by elements from one initializer list.
-
void assign(usize count, const value_type &value)
Replaces elements of the list by several copies of the specified value.
-
auto assign(_InputIt first, _InputIt last) -> enable_if_t<!is_integral_v< _InputIt >, void >
Replaces elements of the list by elements specified by one range. Elements in the range will be copy-inserted into the list.
-
void assign(InitializerList< value_type > ilist)
Replaces elements of the list by elements from one initializer list.
-
List< _Ty, _Alloc >::reference front()
Gets the first element in the list.
-
List< _Ty, _Alloc >::const_reference front() const
Gets the first element in the list.
-
List< _Ty, _Alloc >::reference back()
Gets the last element in the list.
-
List< _Ty, _Alloc >::const_reference back() const
Gets the last element in the list.
-
List< _Ty, _Alloc >::iterator begin()
Gets one iterator to the first element of the list.
-
List< _Ty, _Alloc >::const_iterator begin() const
Gets one constant iterator to the first element of the list.
-
List< _Ty, _Alloc >::const_iterator cbegin() const
Gets one constant iterator to the first element of the list.
-
List< _Ty, _Alloc >::iterator end()
Gets one iterator to the one past last element of the list.
-
List< _Ty, _Alloc >::const_iterator end() const
Gets one constant iterator to the one past last element of the list.
-
List< _Ty, _Alloc >::const_iterator cend() const
Gets one constant iterator to the one past last element of the list.
-
List< _Ty, _Alloc >::reverse_iterator rbegin()
Gets one reverse iterator to the last element of the list.
-
List< _Ty, _Alloc >::const_reverse_iterator rbegin() const
Gets one constant reverse iterator to the last element of the list.
-
List< _Ty, _Alloc >::const_reverse_iterator crbegin() const
Gets one constant reverse iterator to the last element of the list.
-
List< _Ty, _Alloc >::reverse_iterator rend()
Gets one reverse iterator to the one-before-first element of the list.
-
List< _Ty, _Alloc >::const_reverse_iterator rend() const
Gets one constant reverse iterator to the one-before-first element of the list.
-
List< _Ty, _Alloc >::const_reverse_iterator crend() const
Gets one constant reverse iterator to the one-before-first element of the list.
-
Checks whether this list is empty, that is, the size of this list is
0
. -
Gets the size of the list, that is, the number of elements in the list.
-
Removes all elements in the list.
-
List< _Ty, _Alloc >::iterator insert(const_iterator pos, const value_type &value)
Inserts the specified element to the list.
-
List< _Ty, _Alloc >::iterator insert(const_iterator pos, value_type &&value)
Inserts the specified element to the list.
-
List< _Ty, _Alloc >::iterator insert(const_iterator pos, usize count, const value_type &value)
Inserts several copies of the element to the list.
-
Inserts one range of elements to the list.
-
List< _Ty, _Alloc >::iterator insert(const_iterator pos, InitializerList< value_type > ilist)
Inserts one range of elements specified by the initializer list to the list.
-
List< _Ty, _Alloc >::iterator emplace(const_iterator pos, _Args &&... args)
Constructs one element directly on the specified position of the list using the provided arguments.
-
List< _Ty, _Alloc >::iterator erase(const_iterator pos)
Removes one element from the list.
-
List< _Ty, _Alloc >::iterator erase(const_iterator first, const_iterator last)
Removes one range of elements from the list.
-
void push_back(const value_type &value)
Inserts one element at the back of the list.
-
void push_back(value_type &&value)
Inserts one element at the back of the list.
-
List< _Ty, _Alloc >::reference emplace_back(_Args &&... args)
Constructs one element directly on the back of the list using the provided arguments.
-
Removes the last element of the list.
-
void push_front(const value_type &value)
Inserts one element at the front of the list.
-
void push_front(value_type &&value)
Inserts one element at the front of the list.
-
List< _Ty, _Alloc >::reference emplace_front(_Args &&... args)
Constructs one element directly on the front of the list using the provided arguments.
-
Removes the first element of the list.
-
Changes the number of elements in the list.
-
void resize(usize count, const value_type &value)
Changes the number of elements in the list.
-
Swaps elements of this list with the specified list.
-
Merges another list into this list.
-
Merges another list into this list.
-
void merge(List &other, _Compare comp)
Merges another list into this list.
-
void merge(List &&other, _Compare comp)
Merges another list into this list.
-
void splice(const_iterator pos, List &other)
Transfers all elements from another list to this list.
-
void splice(const_iterator pos, List &&other)
Transfers all elements from another list to this list.
-
void splice(const_iterator pos, List &other, const_iterator it)
Transfers one element from another list to this list.
-
void splice(const_iterator pos, List &&other, const_iterator it)
Transfers one element from another list to this list.
-
void splice(const_iterator pos, List &other, const_iterator first, const_iterator last)
Transfers elements from another list to this list.
-
void splice(const_iterator pos, List &&other, const_iterator first, const_iterator last)
Transfers elements from another list to this list.
-
usize remove(const value_type &value)
Removes all elements that are equal to value.
-
usize remove_if(_UnaryPredicate p)
Removes all elements for which the specified predicate returns
true
. -
Reverses the order of the elements in the list.
-
Removes all consecutive duplicate elements from the container.
-
usize unique(_BinaryPredicate p)
Removes all consecutive duplicate elements from the container.
-
Sorts elements in ascending order.
-
Sorts elements in using the user-specified comparison function object.
-
List< _Ty, _Alloc >::allocator_type get_allocator() const
Gets the allocator of the list.