Provides a raw, contiguous memory based LIFO (last-in, first-out) stack.
raw_stack is a lightweight wrapper over std::stack that exposes additional methods such as capacity control, iterators, reserve, and shrink_to_fit. It is intended as a base class for xtd::collections::generic::stack, providing stack-friendly, high-performance stack operations while maintaining the same interface as std::stack.
| type_t | The type of elements stored in the stack. |
| container_t | The underlying container used to store elements. Defaults to std::deque<type_t>. |
Public Aliases | |
| using | base_type |
| The base STL stack type. | |
| using | container_type |
| The underlying container type. | |
| using | value_type |
| Type of elements stored. | |
| using | size_type |
| Unsigned integer type used for size and capacity. | |
| using | reference |
| Reference to element type. | |
| using | const_reference |
| Const reference to element type. | |
| using | const_iterator |
| Const iterator type. | |
| using | const_reverse_iterator |
| Const reverse iterator type. | |
Public Constructors | |
| raw_stack () | |
| Default constructor. Initializes an empty stack. | |
| raw_stack (size_type capacity) | |
| Constructs an empty stack with reserved capacity. | |
| raw_stack (const raw_stack &other) | |
| Copy constructor. | |
| raw_stack (raw_stack &&other) | |
| Move constructor. | |
| template<class input_iterator_t> | |
| raw_stack (input_iterator_t first, input_iterator_t last) | |
| Constructs a stack from a range of iterators. | |
| template<class allocator_t> | |
| raw_stack (const allocator_t &alloc) | |
| Constructs a stack with a specific allocator. | |
Public Properties | |
| auto | begin () const -> const_iterator |
| Gets a const iterator to the beginning of the stack. | |
| auto | capacity () const noexcept -> size_type |
| Gets the reserved capacity of the stack. | |
| auto | cbegin () const -> const_iterator |
| Gets a const iterator to the beginning of the stack. | |
| auto | cend () const -> const_iterator |
| Gets a const iterator to the end of the stack. | |
| auto | crbegin () const -> const_reverse_iterator |
| Gets a const reverse iterator to the beginning of the stack. | |
| auto | crend () const -> const_reverse_iterator |
| Gets a const reverse iterator to the end of the stack. | |
| auto | end () const -> const_iterator |
| Gets a const iterator to the end of the stack. | |
| auto | items () noexcept -> base_type & |
| Access to the underlying base stack. | |
| auto | items () const noexcept -> const base_type & |
| Access to the underlying base stack. | |
| auto | rbegin () const -> const_reverse_iterator |
| Gets a const reverse iterator to the beginning of the stack. | |
| auto | rend () const -> const_reverse_iterator |
| Gets a const reverse iterator to the end of the stack. | |
| auto | size () const noexcept -> size_type |
| Gets the number of elements in the stack. | |
Public Methods | |
| auto | clear () -> void |
| Removes all elements from the stack. | |
| auto | push (const value_type &value) -> void |
| Adds a copy of the element at the back of the stack. | |
| auto | push (value_type &&value) -> void |
| Moves the element into the back of the stack. | |
| auto | pop () -> void |
| Removes the element at the front of the stack. | |
| auto | reserve (size_type count) -> void |
Reserves storage to hold at least count elements. | |
| auto | shrink_to_fit () -> void |
| Reduces capacity to fit the current size. | |
Public Operators | |
| raw_stack & | operator= (const raw_stack &other)=default |
| Copy assignment. | |
| raw_stack & | operator= (raw_stack &&other)=default |
| Move assignment. | |
| operator const base_type & () const noexcept | |
| Cast to const base_type. | |
| operator base_type & () noexcept | |
| Cast to base_type. | |
| using xtd::collections::generic::helpers::raw_stack< type_t, container_t >::base_type |
The base STL stack type.
| using xtd::collections::generic::helpers::raw_stack< type_t, container_t >::container_type |
The underlying container type.
| using xtd::collections::generic::helpers::raw_stack< type_t, container_t >::value_type |
Type of elements stored.
| using xtd::collections::generic::helpers::raw_stack< type_t, container_t >::size_type |
Unsigned integer type used for size and capacity.
| using xtd::collections::generic::helpers::raw_stack< type_t, container_t >::reference |
Reference to element type.
| using xtd::collections::generic::helpers::raw_stack< type_t, container_t >::const_reference |
Const reference to element type.
| using xtd::collections::generic::helpers::raw_stack< type_t, container_t >::const_iterator |
Const iterator type.
| using xtd::collections::generic::helpers::raw_stack< type_t, container_t >::const_reverse_iterator |
Const reverse iterator type.
|
inline |
Default constructor. Initializes an empty stack.
|
inlineexplicit |
Constructs an empty stack with reserved capacity.
| capacity | The initial capacity to reserve. |
|
inline |
Copy constructor.
|
inline |
Move constructor.
| other | Another raw_stack to move from. |
|
inline |
Constructs a stack from a range of iterators.
| input_iterator_t | Input iterator type. |
| first | Iterator to the first element. |
| last | Iterator past the last element. |
|
inlineexplicit |
Constructs a stack with a specific allocator.
|
inline |
Gets a const iterator to the beginning of the stack.
|
inlinenoexcept |
Gets the reserved capacity of the stack.
|
inline |
Gets a const iterator to the beginning of the stack.
|
inline |
Gets a const iterator to the end of the stack.
|
inline |
Gets a const reverse iterator to the beginning of the stack.
|
inline |
Gets a const reverse iterator to the end of the stack.
|
inline |
Gets a const iterator to the end of the stack.
|
inlinenoexcept |
Access to the underlying base stack.
|
inlinenoexcept |
Access to the underlying base stack.
|
inline |
Gets a const reverse iterator to the beginning of the stack.
|
inline |
Gets a const reverse iterator to the end of the stack.
|
inlinenoexcept |
Gets the number of elements in the stack.
|
inline |
Removes all elements from the stack.
|
inline |
Adds a copy of the element at the back of the stack.
| value | The value to push. |
|
inline |
Moves the element into the back of the stack.
| value | The value to push. |
|
inline |
Removes the element at the front of the stack.
|
inline |
Reserves storage to hold at least count elements.
| count | Number of elements to reserve space for. |
|
inline |
Reduces capacity to fit the current size.
|
default |
Copy assignment.
|
default |
Move assignment.
|
inlinenoexcept |
Cast to const base_type.
|
inlinenoexcept |
Cast to base_type.