|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Stack of fixed capacity whose storage is inside the object. More...
#include <tpl_arrayStack.H>
Public Types | |
| using | Item_Type = T |
| The type of element. | |
Public Member Functions | |
| InlineStack () noexcept=default | |
| Construct an empty stack. The storage is not initialized. | |
| InlineStack (const InlineStack &s) noexcept | |
Copy the items in use of s. | |
| InlineStack & | operator= (const InlineStack &s) noexcept |
Assign the items in use of s. | |
| void | swap (InlineStack &s) noexcept |
Exchange the items in use of s and this, in time O(size()). | |
| T & | push (const T &data) noexcept |
Push a copy of data. | |
| T | pop () noexcept |
| Pop the top; the stack must not be empty. | |
| T | popn (const size_t n) noexcept |
Perform n pops in constant time. | |
| T & | top () noexcept |
| Return a modifiable reference to the top; the stack must not be empty. | |
| const T & | top () const noexcept |
See top(). | |
| T & | top (const size_t i) noexcept |
Return a modifiable reference to the item i positions below the top. | |
| const T & | top (const size_t i) const noexcept |
See top(const size_t i). | |
| T & | base () noexcept |
| Return a modifiable reference to the bottom; the stack must not be empty. | |
| const T & | base () const noexcept |
See base(). | |
| bool | is_empty () const noexcept |
Return true if the stack is empty. | |
| size_t | size () const noexcept |
| Return the number of items. | |
| void | empty () noexcept |
| Empty the stack. | |
| void | clear () noexcept |
See empty(). | |
Static Public Member Functions | |
| static constexpr size_t | capacity () noexcept |
| Maximum number of items. | |
Private Attributes | |
| T | array [N] |
| size_t | head = 0 |
Stack of fixed capacity whose storage is inside the object.
Unlike FixedStack, it never allocates: the capacity N is a compile-time constant and the items live in the object, so construction, copy, move and swap cannot throw. Only the items in use are copied or exchanged, so an empty or short stack costs nothing to copy even when N is large.
It is meant for bounded paths that are built and consumed in place: the path from the root of a balanced tree, whose length is bounded by Node::MaxHeight, is the typical one.
No operation checks its preconditions, except by assert(): pushing beyond N or popping an empty stack is a logic error.
| T | type of the items; it must be trivially copyable (pointers, indices). |
| N | maximum number of items. |
Definition at line 740 of file tpl_arrayStack.H.
| using Aleph::InlineStack< T, N >::Item_Type = T |
The type of element.
Definition at line 749 of file tpl_arrayStack.H.
|
defaultnoexcept |
Construct an empty stack. The storage is not initialized.
|
inlinenoexcept |
Copy the items in use of s.
Definition at line 755 of file tpl_arrayStack.H.
References Aleph::InlineStack< T, N >::array, and Aleph::InlineStack< T, N >::head.
|
inlinenoexcept |
See base().
Definition at line 854 of file tpl_arrayStack.H.
References Aleph::InlineStack< T, N >::array, and Aleph::InlineStack< T, N >::head.
|
inlinenoexcept |
Return a modifiable reference to the bottom; the stack must not be empty.
Definition at line 847 of file tpl_arrayStack.H.
References Aleph::InlineStack< T, N >::array, and Aleph::InlineStack< T, N >::head.
|
inlinestaticconstexprnoexcept |
Maximum number of items.
Definition at line 781 of file tpl_arrayStack.H.
References N.
Referenced by TEST().
|
inlinenoexcept |
See empty().
Definition at line 879 of file tpl_arrayStack.H.
References Aleph::InlineStack< T, N >::head.
Referenced by TEST().
|
inlinenoexcept |
Empty the stack.
Definition at line 873 of file tpl_arrayStack.H.
References Aleph::InlineStack< T, N >::head.
Referenced by Aleph::GenBinHeap< NodeType, Key, Compare >::Iterator::end(), Aleph::GenBinHeap< NodeType, Key, Compare >::Iterator::reset_first(), Aleph::GenBinHeap< NodeType, Key, Compare >::Iterator::reset_last(), and TEST().
|
inlinenoexcept |
Return true if the stack is empty.
Definition at line 861 of file tpl_arrayStack.H.
References Aleph::InlineStack< T, N >::head.
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::extract_max(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::extract_min(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_exclusive(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::join_exclusive(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_left(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_right(), Aleph::GenBinHeap< NodeType, Key, Compare >::Iterator::next_ne(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_key(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_dup(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_key_dup(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_pos(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_pos(), TEST(), TEST(), TEST(), and TEST().
|
inlinenoexcept |
Assign the items in use of s.
Definition at line 762 of file tpl_arrayStack.H.
References Aleph::InlineStack< T, N >::array, and Aleph::InlineStack< T, N >::head.
|
inlinenoexcept |
Pop the top; the stack must not be empty.
Definition at line 798 of file tpl_arrayStack.H.
References Aleph::InlineStack< T, N >::array, and Aleph::InlineStack< T, N >::head.
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::extract_max(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::extract_min(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::fix_black_condition(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::fix_red_condition(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_exclusive(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::join_exclusive(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_left(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_right(), Aleph::GenBinHeap< NodeType, Key, Compare >::Iterator::next_ne(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_key(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_dup(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_key_dup(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_pos(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_pos(), TEST(), and TEST().
|
inlinenoexcept |
Perform n pops in constant time.
| [in] | n | number of items to pop; at most size(). |
Definition at line 808 of file tpl_arrayStack.H.
References Aleph::InlineStack< T, N >::array, and Aleph::InlineStack< T, N >::head.
Referenced by Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::fix_black_condition(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::search_and_stack_rb(), and TEST().
|
inlinenoexcept |
Push a copy of data.
| [in] | data | item to push; the stack must not be full. |
Definition at line 790 of file tpl_arrayStack.H.
References Aleph::InlineStack< T, N >::array, and Aleph::InlineStack< T, N >::head.
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::extract_max(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::extract_min(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::find_succ_and_swap(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::insert(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::insert(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::insert_dup(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::insert_dup(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_exclusive(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::join_exclusive(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_left(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_right(), Aleph::GenBinHeap< NodeType, Key, Compare >::Iterator::next_ne(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::remove(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::remove(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::search_and_stack_rb(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::search_dup_and_stack_rb(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::search_or_insert(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_or_insert(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_key(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_dup(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_key_dup(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_pos(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_pos(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inlinenoexcept |
Return the number of items.
Definition at line 867 of file tpl_arrayStack.H.
References Aleph::InlineStack< T, N >::head.
Referenced by Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::search_and_stack_rb(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inlinenoexcept |
Exchange the items in use of s and this, in time O(size()).
Definition at line 773 of file tpl_arrayStack.H.
Referenced by TEST().
|
inlinenoexcept |
See top().
Definition at line 823 of file tpl_arrayStack.H.
References Aleph::InlineStack< T, N >::array, and Aleph::InlineStack< T, N >::head.
|
inlinenoexcept |
Return a modifiable reference to the top; the stack must not be empty.
Definition at line 816 of file tpl_arrayStack.H.
References Aleph::InlineStack< T, N >::array, and Aleph::InlineStack< T, N >::head.
Referenced by Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::find_succ_and_swap(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::fix_black_condition(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::remove(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::remove(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::remove(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::remove(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::search_and_stack_rb(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::search_dup_and_stack_rb(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inlinenoexcept |
See top(const size_t i).
Definition at line 840 of file tpl_arrayStack.H.
References Aleph::InlineStack< T, N >::array, and Aleph::InlineStack< T, N >::head.
|
inlinenoexcept |
Return a modifiable reference to the item i positions below the top.
| [in] | i | number of positions; top(0) is the top. |
Definition at line 833 of file tpl_arrayStack.H.
References Aleph::InlineStack< T, N >::array, and Aleph::InlineStack< T, N >::head.
Definition at line 745 of file tpl_arrayStack.H.
Referenced by Aleph::InlineStack< T, N >::InlineStack(), Aleph::InlineStack< T, N >::base(), Aleph::InlineStack< T, N >::base(), Aleph::InlineStack< T, N >::operator=(), Aleph::InlineStack< T, N >::pop(), Aleph::InlineStack< T, N >::popn(), Aleph::InlineStack< T, N >::push(), Aleph::InlineStack< T, N >::top(), Aleph::InlineStack< T, N >::top(), Aleph::InlineStack< T, N >::top(), and Aleph::InlineStack< T, N >::top().
|
private |
Definition at line 746 of file tpl_arrayStack.H.
Referenced by Aleph::InlineStack< T, N >::InlineStack(), Aleph::InlineStack< T, N >::base(), Aleph::InlineStack< T, N >::base(), Aleph::InlineStack< T, N >::clear(), Aleph::InlineStack< T, N >::empty(), Aleph::InlineStack< T, N >::is_empty(), Aleph::InlineStack< T, N >::operator=(), Aleph::InlineStack< T, N >::pop(), Aleph::InlineStack< T, N >::popn(), Aleph::InlineStack< T, N >::push(), Aleph::InlineStack< T, N >::size(), Aleph::InlineStack< T, N >::top(), Aleph::InlineStack< T, N >::top(), Aleph::InlineStack< T, N >::top(), and Aleph::InlineStack< T, N >::top().