Doubly linked list stored on Base's heap. More...
#include <StormByte/safe/list.hxx>
Classes | |
| class | BasicIterator |
| Bidirectional cursor over Base-owned list nodes. More... | |
| class | node_type |
| Owning handle to one extracted Base node. More... | |
Public Types | |
| using | value_type = T |
| Element type. | |
| using | size_type = Size |
| Element count. Size, not std::size_t. | |
| using | difference_type = std::ptrdiff_t |
| Iterator distance type. | |
| using | reference = T& |
| Mutable element reference. | |
| using | const_reference = const T& |
| Read-only element reference. | |
| using | iterator = BasicIterator<false> |
| Mutable iterator. | |
| using | const_iterator = BasicIterator<true> |
| Read-only iterator. | |
| using | reverse_iterator = std::reverse_iterator<iterator> |
| Mutable reverse iterator. | |
| using | const_reverse_iterator = std::reverse_iterator<const_iterator> |
| Read-only reverse iterator. | |
Public Member Functions | |
| List () noexcept | |
| Construct an empty list. | |
| List (size_type count) | |
Construct count value-initialized elements. | |
| List (size_type count, const T &value) | |
Construct count copies of value. | |
| List (const List &other) | |
| Copy every node into new Base blocks. | |
| List (List &&other) noexcept | |
| Take the chain. | |
| STORMBYTE_FORCE_INLINE | List (const std::list< T > &other) |
| Copy a caller-owned STL list. | |
| STORMBYTE_FORCE_INLINE | List (std::list< T > &&other) |
| Move elements from a caller-owned STL list and leave it empty. | |
| template<std::ranges::input_range R> requires std::convertible_to<std::ranges::range_reference_t<R>, T> | |
| STORMBYTE_FORCE_INLINE | List (std::from_range_t, R &&range) |
Copy the elements of range. | |
| List (std::initializer_list< T > values) | |
| Insert every element of an initializer list. | |
| ~List () noexcept | |
| Destroy every node through Base. | |
| List & | operator= (const List &other) |
| Copy-assign. | |
| List & | operator= (List &&other) noexcept |
| Move-assign. | |
| List & | operator= (std::initializer_list< T > values) |
| Replace the contents with an initializer list. | |
| void | assign (size_type count, const T &value) |
Replace the contents with count copies of value. | |
| void | assign (std::initializer_list< T > values) |
| Replace the contents with an initializer list. | |
| template<std::ranges::input_range R> requires std::convertible_to<std::ranges::range_reference_t<R>, T> | |
| STORMBYTE_FORCE_INLINE void | assign_range (R &&range) |
Replace the contents with range. | |
| T & | front () noexcept |
| Return the first element. | |
| const T & | front () const noexcept |
| Return the first element. | |
| T & | back () noexcept |
| Return the last element. | |
| const T & | back () const noexcept |
| Return the last element. | |
| iterator | begin () noexcept |
| Return the first element. | |
| iterator | end () noexcept |
| Return the past-the-end iterator. | |
| const_iterator | begin () const noexcept |
| Return the first element. | |
| const_iterator | end () const noexcept |
| Return the past-the-end iterator. | |
| const_iterator | cbegin () const noexcept |
| Return the first element. | |
| const_iterator | cend () const noexcept |
| Return the past-the-end iterator. | |
| reverse_iterator | rbegin () noexcept |
| Return a reverse iterator to the last element. | |
| reverse_iterator | rend () noexcept |
| Return the reverse past-the-end iterator. | |
| const_reverse_iterator | rbegin () const noexcept |
| Return a reverse iterator to the last element. | |
| const_reverse_iterator | rend () const noexcept |
| Return the reverse past-the-end iterator. | |
| const_reverse_iterator | crbegin () const noexcept |
| Return a reverse iterator to the last element. | |
| const_reverse_iterator | crend () const noexcept |
| Return the reverse past-the-end iterator. | |
| bool | empty () const noexcept |
| Test whether the list holds no elements. | |
| size_type | size () const noexcept |
| Return the element count. | |
| size_type | max_size () const noexcept |
| Return the maximum element count this list can report. | |
| void | clear () noexcept |
| Destroy every element. | |
| iterator | insert (const_iterator position, const T &value) |
Insert a copy of value before position. | |
| iterator | insert (const_iterator position, T &&value) |
Insert a moved value before position. | |
| iterator | insert (const_iterator position, size_type count, const T &value) |
Insert count copies of value before position. | |
| iterator | insert (const_iterator position, std::initializer_list< T > values) |
Insert every element of an initializer list before position. | |
| template<std::ranges::input_range R> requires std::convertible_to<std::ranges::range_reference_t<R>, T> | |
| STORMBYTE_FORCE_INLINE iterator | insert_range (const_iterator position, R &&range) |
Insert every element of range before position. | |
| template<class... Args> | |
| iterator | emplace (const_iterator position, Args &&... args) |
Construct an element in place before position. | |
| iterator | erase (const_iterator position) |
Erase the element at position. | |
| iterator | erase (const_iterator first, const_iterator last) |
Erase the half-open range [first, last). | |
| void | push_front (const T &value) |
Copy value to the front. | |
| void | push_front (T &&value) |
Move value to the front. | |
| template<class... Args> | |
| T & | emplace_front (Args &&... args) |
| Construct an element at the front. | |
| void | pop_front () noexcept |
| Destroy the first element. | |
| void | push_back (const T &value) |
Copy value to the back. | |
| void | push_back (T &&value) |
Move value to the back. | |
| template<class... Args> | |
| T & | emplace_back (Args &&... args) |
| Construct an element at the back. | |
| void | pop_back () noexcept |
| Destroy the last element. | |
| void | resize (size_type count) |
Grow or shrink to count. | |
| void | resize (size_type count, const T &value) |
Grow or shrink to count. | |
| void | swap (List &other) noexcept |
| Exchange chains. | |
| void | splice (const_iterator position, List &other) noexcept |
Relink every node of other before position. | |
| void | splice (const_iterator position, List &other, const_iterator source) noexcept |
Relink the node at source before position. | |
| void | splice (const_iterator position, List &other, const_iterator first, const_iterator last) noexcept |
Relink [first, last) before position. | |
| node_type | extract (const_iterator position) |
Unlink the element at position. | |
| iterator | insert (const_iterator position, node_type &&node) |
Link an extracted node before position. | |
| void | merge (List &other) |
Move the ordered nodes of other into this ordered list. | |
| template<class Compare> | |
| void | merge (List &other, Compare compare) |
Move the ordered nodes of other into this ordered list. | |
| size_type | remove (const T &value) |
Erase every element equal to value. | |
| template<class Predicate> | |
| size_type | remove_if (Predicate predicate) |
Erase every element for which predicate is true. | |
| void | reverse () noexcept |
| Reverse the chain. | |
| size_type | unique () |
| Erase consecutive duplicates. | |
| template<class Predicate> | |
| size_type | unique (Predicate predicate) |
Erase consecutive elements for which predicate is true. | |
| void | sort () |
| Sort the chain. | |
| template<class Compare> | |
| void | sort (Compare compare) |
| Sort the chain. | |
| bool | operator== (const List &other) const |
| Compare elements in order. | |
| STORMBYTE_FORCE_INLINE std::strong_ordering | operator<=> (const List &other) const |
| Order the lists lexicographically. | |
| STORMBYTE_FORCE_INLINE | operator std::list< T > () const |
| Copy the elements into caller-owned STL storage. | |
Doubly linked list stored on Base's heap.
| T | Safe value type. |
Nodes are allocated with Heap::Allocate. There is no allocator. The sentinel lives in the list object, so an empty list does not construct a T. Iterators are bidirectional and point at Base nodes. node_type owns a Base node. It is not std::list::node_type. extract, splice and merge relink that node. They do not copy it. A conversion to or from std::list copies the elements.
| using StormByte::Safe::List< T >::const_iterator = BasicIterator<true> |
Read-only iterator.
| using StormByte::Safe::List< T >::const_reference = const T& |
Read-only element reference.
| using StormByte::Safe::List< T >::const_reverse_iterator = std::reverse_iterator<const_iterator> |
Read-only reverse iterator.
| using StormByte::Safe::List< T >::difference_type = std::ptrdiff_t |
Iterator distance type.
| using StormByte::Safe::List< T >::iterator = BasicIterator<false> |
Mutable iterator.
| using StormByte::Safe::List< T >::reference = T& |
Mutable element reference.
| using StormByte::Safe::List< T >::reverse_iterator = std::reverse_iterator<iterator> |
Mutable reverse iterator.
| using StormByte::Safe::List< T >::size_type = Size |
Element count. Size, not std::size_t.
| using StormByte::Safe::List< T >::value_type = T |
Element type.
|
noexcept |
Construct an empty list.
|
explicit |
Construct count value-initialized elements.
| count | Element count. |
| AllocationError | A node could not be allocated. |
| StormByte::Safe::List< T >::List | ( | size_type | count, |
| const T & | value ) |
Construct count copies of value.
| count | Element count. |
| value | Element to copy. |
| AllocationError | A node could not be allocated. |
| StormByte::Safe::List< T >::List | ( | const List< T > & | other | ) |
Copy every node into new Base blocks.
| other | Source. |
| AllocationError | A node could not be allocated. |
|
noexcept |
Take the chain.
other is left empty.
| other | Source. |
|
inlineexplicit |
Copy a caller-owned STL list.
Its state is unchanged.
| other | Source. |
| AllocationError | A node could not be allocated. |
|
inlineexplicit |
Move elements from a caller-owned STL list and leave it empty.
| other | Source. Cleared before this function returns. |
| AllocationError | A node could not be allocated. |
|
inlineexplicit |
Copy the elements of range.
| R | Input range of T. |
| range | Source. Instantiated in the caller. |
| AllocationError | A node could not be allocated. |
| StormByte::Safe::List< T >::List | ( | std::initializer_list< T > | values | ) |
Insert every element of an initializer list.
| values | Elements. |
| AllocationError | A node could not be allocated. |
|
noexcept |
Destroy every node through Base.
| void StormByte::Safe::List< T >::assign | ( | size_type | count, |
| const T & | value ) |
Replace the contents with count copies of value.
| count | Element count. |
| value | Element to copy. |
| AllocationError | A node could not be allocated. |
| void StormByte::Safe::List< T >::assign | ( | std::initializer_list< T > | values | ) |
Replace the contents with an initializer list.
| values | Elements. |
| AllocationError | A node could not be allocated. |
|
inline |
Replace the contents with range.
| R | Input range of T. |
| range | Source. Instantiated in the caller. |
| AllocationError | A node could not be allocated. |
|
inlinenoexcept |
Return the last element.
|
inlinenoexcept |
Return the last element.
|
inlinenoexcept |
Return the first element.
|
inlinenoexcept |
Return the first element.
|
inlinenoexcept |
Return the first element.
|
inlinenoexcept |
Return the past-the-end iterator.
|
noexcept |
Destroy every element.
The sentinel stays.
|
inlinenoexcept |
Return a reverse iterator to the last element.
|
inlinenoexcept |
Return the reverse past-the-end iterator.
| iterator StormByte::Safe::List< T >::emplace | ( | const_iterator | position, |
| Args &&... | args ) |
Construct an element in place before position.
| Args | Constructor argument types. |
| position | Insertion point. |
| args | Arguments forwarded to T. |
| AllocationError | A node could not be allocated. |
| T & StormByte::Safe::List< T >::emplace_back | ( | Args &&... | args | ) |
Construct an element at the back.
| Args | Constructor argument types. |
| args | Arguments forwarded to T. |
| AllocationError | A node could not be allocated. |
| T & StormByte::Safe::List< T >::emplace_front | ( | Args &&... | args | ) |
Construct an element at the front.
| Args | Constructor argument types. |
| args | Arguments forwarded to T. |
| AllocationError | A node could not be allocated. |
|
inlinenoexcept |
Test whether the list holds no elements.
|
inlinenoexcept |
Return the past-the-end iterator.
|
inlinenoexcept |
Return the past-the-end iterator.
| iterator StormByte::Safe::List< T >::erase | ( | const_iterator | first, |
| const_iterator | last ) |
Erase the half-open range [first, last).
| first | First element to erase. |
| last | One past the last element to erase. |
last. | iterator StormByte::Safe::List< T >::erase | ( | const_iterator | position | ) |
Erase the element at position.
| position | Iterator to an element. Not end. |
| node_type StormByte::Safe::List< T >::extract | ( | const_iterator | position | ) |
Unlink the element at position.
The node is not copied.
| position | Iterator to an element. Not end. |
|
inlinenoexcept |
Return the first element.
|
inlinenoexcept |
Return the first element.
| iterator StormByte::Safe::List< T >::insert | ( | const_iterator | position, |
| const T & | value ) |
Insert a copy of value before position.
| position | Insertion point. |
| value | Element. |
| AllocationError | A node could not be allocated. |
| iterator StormByte::Safe::List< T >::insert | ( | const_iterator | position, |
| node_type && | node ) |
Link an extracted node before position.
| position | Insertion point. |
| node | Handle. Left empty. |
position when node is empty. | iterator StormByte::Safe::List< T >::insert | ( | const_iterator | position, |
| size_type | count, | ||
| const T & | value ) |
Insert count copies of value before position.
| position | Insertion point. |
| count | Copy count. |
| value | Element. |
position when count is zero. | AllocationError | A node could not be allocated. |
| iterator StormByte::Safe::List< T >::insert | ( | const_iterator | position, |
| std::initializer_list< T > | values ) |
Insert every element of an initializer list before position.
| position | Insertion point. |
| values | Elements. |
position when values is empty. | AllocationError | A node could not be allocated. |
| iterator StormByte::Safe::List< T >::insert | ( | const_iterator | position, |
| T && | value ) |
Insert a moved value before position.
| position | Insertion point. |
| value | Element. |
| AllocationError | A node could not be allocated. |
|
inline |
Insert every element of range before position.
| R | Input range of T. |
| position | Insertion point. |
| range | Source. Instantiated in the caller. |
position when range is empty. | AllocationError | A node could not be allocated. |
|
inlinenoexcept |
Return the maximum element count this list can report.
| void StormByte::Safe::List< T >::merge | ( | List< T > & | other | ) |
Move the ordered nodes of other into this ordered list.
| other | Source. Left with the nodes that were not taken. Both lists are ordered by operator<. |
| void StormByte::Safe::List< T >::merge | ( | List< T > & | other, |
| Compare | compare ) |
Move the ordered nodes of other into this ordered list.
| Compare | Strict weak ordering. |
| other | Source. |
| compare | Element ordering. |
|
inlineexplicit |
Copy the elements into caller-owned STL storage.
| STORMBYTE_FORCE_INLINE std::strong_ordering StormByte::Safe::List< T >::operator<=> | ( | const List< T > & | other | ) | const |
Order the lists lexicographically.
| other | List to compare. |
| List & StormByte::Safe::List< T >::operator= | ( | const List< T > & | other | ) |
Copy-assign.
The previous chain is released only after the copy exists.
| other | Source. |
| AllocationError | A node could not be allocated. |
|
noexcept |
Move-assign.
other is left empty.
| other | Source. |
| List & StormByte::Safe::List< T >::operator= | ( | std::initializer_list< T > | values | ) |
Replace the contents with an initializer list.
| values | Elements. |
| AllocationError | A node could not be allocated. |
| bool StormByte::Safe::List< T >::operator== | ( | const List< T > & | other | ) | const |
Compare elements in order.
| other | List to compare. |
|
noexcept |
Destroy the last element.
The list is not empty.
|
noexcept |
Destroy the first element.
The list is not empty.
| void StormByte::Safe::List< T >::push_back | ( | const T & | value | ) |
Copy value to the back.
| value | Element. |
| AllocationError | A node could not be allocated. |
| void StormByte::Safe::List< T >::push_back | ( | T && | value | ) |
Move value to the back.
| value | Element. |
| AllocationError | A node could not be allocated. |
| void StormByte::Safe::List< T >::push_front | ( | const T & | value | ) |
Copy value to the front.
| value | Element. |
| AllocationError | A node could not be allocated. |
| void StormByte::Safe::List< T >::push_front | ( | T && | value | ) |
Move value to the front.
| value | Element. |
| AllocationError | A node could not be allocated. |
|
inlinenoexcept |
Return a reverse iterator to the last element.
|
inlinenoexcept |
Return a reverse iterator to the last element.
| size_type StormByte::Safe::List< T >::remove | ( | const T & | value | ) |
Erase every element equal to value.
| value | Element to erase. |
| size_type StormByte::Safe::List< T >::remove_if | ( | Predicate | predicate | ) |
Erase every element for which predicate is true.
| Predicate | Unary predicate. |
| predicate | Erase condition. |
|
inlinenoexcept |
Return the reverse past-the-end iterator.
|
inlinenoexcept |
Return the reverse past-the-end iterator.
| void StormByte::Safe::List< T >::resize | ( | size_type | count | ) |
Grow or shrink to count.
New elements are value-initialized.
| count | New element count. |
| AllocationError | A node could not be allocated. |
| void StormByte::Safe::List< T >::resize | ( | size_type | count, |
| const T & | value ) |
Grow or shrink to count.
New elements are copies of value.
| count | New element count. |
| value | Element to copy. |
| AllocationError | A node could not be allocated. |
|
noexcept |
Reverse the chain.
Does not allocate.
|
inlinenoexcept |
Return the element count.
| void StormByte::Safe::List< T >::sort | ( | ) |
Sort the chain.
Ordering is operator<. Nodes are relinked, not copied.
| void StormByte::Safe::List< T >::sort | ( | Compare | compare | ) |
Sort the chain.
Nodes are relinked, not copied.
| Compare | Strict weak ordering. |
| compare | Element ordering. |
|
noexcept |
Relink every node of other before position.
other is left empty.
| position | Insertion point. |
| other | Source. Not this list. |
|
noexcept |
Relink [first, last) before position.
| position | Insertion point. |
| other | List that owns the range. |
| first | First element to relink. |
| last | One past the last element to relink. |
|
noexcept |
|
noexcept |
| size_type StormByte::Safe::List< T >::unique | ( | ) |
Erase consecutive duplicates.
Equality is operator==.
| size_type StormByte::Safe::List< T >::unique | ( | Predicate | predicate | ) |
Erase consecutive elements for which predicate is true.
| Predicate | Binary predicate. |
| predicate | Duplicate condition. |