template<typename T>
class pw::ForwardList< T >
A singly-linked list that owns its elements and allocates them using a pw::Allocator. It provides an interface similar to std::forward_list.
ForwardList is an owning wrapper around IntrusiveForwardList that manages the lifetime and dynamic memory allocation of its elements. It provides both asserting operations (such as push_front and resize) and fallible try_* operations (such as try_push_front and try_resize) for allocation-failure handling without exceptions.
- Warning
- The container's allocator MUST outlive the container.
- Template Parameters
-
| T | The type of elements in the list. |
|
| constexpr | ForwardList (Allocator &allocator) noexcept |
| |
|
| ~ForwardList () |
| | Destroys the ForwardList and deallocates all stored elements.
|
| |
|
| ForwardList (const ForwardList &)=delete |
| |
|
ForwardList & | operator= (const ForwardList &)=delete |
| |
|
| ForwardList (ForwardList &&other) noexcept |
| | Moves the elements and allocator from other into this list.
|
| |
|
ForwardList & | operator= (ForwardList &&other) noexcept |
| | Move-assigns other into this list, clearing existing elements first.
|
| |
|
iterator | before_begin () noexcept |
| | Returns an iterator to the element before the first element of the list.
|
| |
| const_iterator | before_begin () const noexcept |
| |
| const_iterator | cbefore_begin () const noexcept |
| |
|
iterator | begin () noexcept |
| | Returns an iterator to the first element in the list.
|
| |
|
const_iterator | begin () const noexcept |
| | Returns a const iterator to the first element in the list.
|
| |
|
const_iterator | cbegin () const noexcept |
| | Returns a const iterator to the first element in the list.
|
| |
|
iterator | end () noexcept |
| | Returns an iterator to the end of the list.
|
| |
|
const_iterator | end () const noexcept |
| | Returns a const iterator to the end of the list.
|
| |
|
const_iterator | cend () const noexcept |
| | Returns a const iterator to the end of the list.
|
| |
|
allocator_type & | get_allocator () const noexcept |
| | Returns a reference to the allocator associated with this container.
|
| |
|
bool | empty () const noexcept |
| | Checks whether the container is empty.
|
| |
|
constexpr size_type | max_size () const noexcept |
| | Returns the maximum possible number of elements the list can hold.
|
| |
|
reference | front () noexcept |
| | Returns a reference to the first element.
|
| |
|
const_reference | front () const noexcept |
| | Returns a const reference to the first element.
|
| |
| template<typename... Args> |
| reference | emplace_front (Args &&... args) |
| |
| template<typename... Args> |
| bool | try_emplace_front (Args &&... args) |
| |
| void | push_front (const T &value) |
| |
| void | push_front (T &&value) |
| |
| bool | try_push_front (const T &value) |
| |
| bool | try_push_front (T &&value) |
| |
| void | pop_front () noexcept |
| |
|
void | clear () noexcept |
| | Erases all elements from the container and frees their allocated nodes.
|
| |
| void | swap (ForwardList &other) noexcept |
| |
| template<typename... Args> |
| iterator | emplace_after (const_iterator pos, Args &&... args) |
| |
| template<typename... Args> |
| bool | try_emplace_after (const_iterator pos, Args &&... args) |
| |
| iterator | insert_after (const_iterator pos, const T &value) |
| |
| iterator | insert_after (const_iterator pos, T &&value) |
| |
|
bool | try_insert_after (const_iterator pos, const T &value) |
| | Attempts to insert a copy of value after pos.
|
| |
|
bool | try_insert_after (const_iterator pos, T &&value) |
| | Attempts to insert value after pos via move.
|
| |
| iterator | insert_after (const_iterator pos, size_type count, const T &value) |
| |
| bool | try_insert_after (const_iterator pos, size_type count, const T &value) |
| |
| template<typename InputIt , typename = std::enable_if_t<!std::is_integral_v<InputIt>>> |
| iterator | insert_after (const_iterator pos, InputIt first, InputIt last) |
| |
| template<typename InputIt , typename = std::enable_if_t<!std::is_integral_v<InputIt>>> |
| bool | try_insert_after (const_iterator pos, InputIt first, InputIt last) |
| |
| iterator | insert_after (const_iterator pos, std::initializer_list< T > ilist) |
| |
|
bool | try_insert_after (const_iterator pos, std::initializer_list< T > ilist) |
| | Attempts to insert elements from ilist after pos.
|
| |
| void | assign (size_type count, const T &value) |
| |
| bool | try_assign (size_type count, const T &value) |
| |
| template<typename InputIt , typename = std::enable_if_t<!std::is_integral_v<InputIt>>> |
| void | assign (InputIt first, InputIt last) |
| |
| template<typename InputIt , typename = std::enable_if_t<!std::is_integral_v<InputIt>>> |
| bool | try_assign (InputIt first, InputIt last) |
| |
| void | assign (std::initializer_list< T > ilist) |
| |
| bool | try_assign (std::initializer_list< T > ilist) |
| |
| iterator | erase_after (const_iterator pos) |
| |
| iterator | erase_after (const_iterator first, const_iterator last) |
| |
| void | resize (size_type count) |
| |
| void | resize (size_type count, const T &value) |
| |
| bool | try_resize (size_type count) |
| |
| bool | try_resize (size_type count, const T &value) |
| |
|
void | splice_after (const_iterator pos, ForwardList &other) noexcept |
| | Moves all elements from other into this list after pos.
|
| |
|
void | splice_after (const_iterator pos, ForwardList &&other) noexcept |
| | Moves all elements from other into this list after pos.
|
| |
|
void | splice_after (const_iterator pos, ForwardList &other, const_iterator it) noexcept |
| | Moves the element pointed to after it from other to after pos.
|
| |
|
void | splice_after (const_iterator pos, ForwardList &&other, const_iterator it) noexcept |
| | Moves the element pointed to after it from other to after pos.
|
| |
| void | splice_after (const_iterator pos, ForwardList &other, const_iterator first, const_iterator last) noexcept |
| |
| void | splice_after (const_iterator pos, ForwardList &&other, const_iterator first, const_iterator last) noexcept |
| |
| size_type | remove (const T &value) |
| |
| template<typename UnaryPredicate > |
| size_type | remove_if (UnaryPredicate pred) |
| |
| size_type | unique () |
| |
| template<typename BinaryPredicate > |
| size_type | unique (BinaryPredicate binary_pred) |
| |
|
void | merge (ForwardList &other) |
| | Merges two sorted lists into one using operator<.
|
| |
|
void | merge (ForwardList &&other) |
| | Merges two sorted lists into one using operator<.
|
| |
|
template<typename Compare > |
| void | merge (ForwardList &other, Compare comp) |
| | Merges two sorted lists into one using the comparator comp.
|
| |
|
template<typename Compare > |
| void | merge (ForwardList &&other, Compare comp) |
| | Merges two sorted lists into one using the comparator comp.
|
| |
|
void | sort () |
| | Sorts the elements in non-descending order using operator<.
|
| |
|
template<typename Compare > |
| void | sort (Compare comp) |
| | Sorts the elements in non-descending order using the comparator comp.
|
| |
|
void | reverse () noexcept |
| | Reverses the order of the elements in the list.
|
| |