A generic internal stack.
More...
#include <tpie/internal_stack.h>
Inherits tpie::internal_stack_vector_base< T, internal_stack< T > >.
|
| | internal_stack (size_t size=0) |
| | Construct structure with given capacity. More...
|
| |
| T & | top () |
| | Return the topmost element on the stack. More...
|
| |
| void | push (const T &val) |
| | Add an element to the top of the stack. More...
|
| |
| void | pop () |
| | Remove the topmost element from the stack. More...
|
| |
| void | resize (size_t size=0) |
| | Change the capacity of the structure and clear all elements. More...
|
| |
| bool | empty () const |
| | Check if no elements are currently pushed to the structure. More...
|
| |
| size_t | size () const |
| | Return the number of elements in the data structure. More...
|
| |
| void | clear () |
| | Clear the data structure of all elements. More...
|
| |
|
| static double | memory_coefficient () |
| | Return the memory coefficient of the structure. More...
|
| |
| static double | memory_overhead () |
| | Return the memory overhead of the structure. More...
|
| |
| static constexpr memory_size_type | memory_usage (memory_size_type size) noexcept |
| | Return the number of bytes required to create a data structure supporting a given number of elements. More...
|
| |
|
static constexpr linear_memory_usage | memory_usage () noexcept |
| |
| static constexpr memory_size_type | memory_fits (memory_size_type memory) noexcept |
| | Return the maximum number of elements that can be contained in in the structure when it is allowed to fill a given number of bytes. More...
|
| |
template<typename T>
class tpie::internal_stack< T >
A generic internal stack.
- Template Parameters
-
| T | The type of items stored in the structure. |
Definition at line 37 of file internal_stack.h.
◆ internal_stack()
Construct structure with given capacity.
If a zero capacity is given (the default), no elements may be pushed to the structure until the structure is resized to a different capacity.
- Parameters
-
| size | Capacity of the structure. |
Definition at line 45 of file internal_stack.h.
◆ clear()
◆ empty()
◆ memory_coefficient()
Return the memory coefficient of the structure.
Allocating a structure with n elements will use at most \( \lfloor \mathrm{memory\_coefficient} \cdot n + \mathrm{memory\_overhead} \rfloor \) bytes. This does not include memory overhead incurred if the structure is allocated using new.
- Returns
- The memory coefficient of the structure.
Definition at line 51 of file internal_stack_vector_base.h.
◆ memory_fits()
|
|
inlinestaticconstexprnoexceptinherited |
Return the maximum number of elements that can be contained in in the structure when it is allowed to fill a given number of bytes.
- Parameters
-
| memory | The number of bytes the structure is allowed to occupy |
- Returns
- The number of elements that will fit in the structure
Definition at line 118 of file util.h.
119 return static_cast<memory_size_type
>(
120 floor((memory - child_t::memory_overhead()) / child_t::memory_coefficient()));
◆ memory_overhead()
◆ memory_usage()
|
|
inlinestaticconstexprnoexceptinherited |
Return the number of bytes required to create a data structure supporting a given number of elements.
- Parameters
-
| size | The number of elements to support |
- Returns
- The amount of memory required in bytes
Definition at line 106 of file util.h.
107 return static_cast<memory_size_type
>(
108 floor(
static_cast<double>(size) * child_t::memory_coefficient() + child_t::memory_overhead()));
◆ pop()
◆ push()
◆ resize()
Change the capacity of the structure and clear all elements.
- Parameters
-
| size | New capacity of the structure. |
Definition at line 77 of file internal_stack_vector_base.h.
◆ size()
◆ top()
◆ m_elements
◆ m_size
The documentation for this class was generated from the following file: