A generic internal stack. More...
#include <tpie/internal_stack.h>
Inherits tpie::internal_stack_vector_base< T, internal_stack< T > >.
Public Types | |
typedef internal_stack_vector_base< T, internal_stack< T > > | parent_t |
typedef T | value_type |
Public Member Functions | |
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 Public Member Functions | |
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 memory_size_type | memory_usage (memory_size_type size) |
Return the number of bytes required to create a data structure supporting a given number of elements. More... | |
static memory_size_type | memory_fits (memory_size_type memory) |
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... | |
Protected Attributes | |
array< T > | m_elements |
Element storage. More... | |
size_t | m_size |
Number of elements pushed to the structure. More... | |
A generic internal stack.
T | The type of items stored in the structure. |
Definition at line 37 of file internal_stack.h.
|
inline |
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 resize
d to a different capacity.
size | Capacity of the structure. |
Definition at line 45 of file internal_stack.h.
|
inlineinherited |
Clear the data structure of all elements.
Definition at line 92 of file internal_stack_vector_base.h.
References tpie::internal_stack_vector_base< T, child_t >::m_size.
|
inlineinherited |
Check if no elements are currently pushed to the structure.
Definition at line 82 of file internal_stack_vector_base.h.
References tpie::internal_stack_vector_base< T, child_t >::m_size.
|
inlinestaticinherited |
Return the memory coefficient of the structure.
Allocating a structure with n elements will use at most bytes. This does not include memory overhead incurred if the structure is allocated using new.
Definition at line 51 of file internal_stack_vector_base.h.
References tpie::array< T, Allocator >::memory_coefficient().
|
inlinestaticinherited |
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.
memory | The number of bytes the structure is allowed to occupy |
|
inlinestaticinherited |
Return the memory overhead of the structure.
Definition at line 56 of file internal_stack_vector_base.h.
References tpie::array< T, Allocator >::memory_overhead().
|
inlinestaticinherited |
Return the number of bytes required to create a data structure supporting a given number of elements.
size | The number of elements to support |
|
inline |
Remove the topmost element from the stack.
Definition at line 67 of file internal_stack.h.
References tpie::internal_stack_vector_base< T, internal_stack< T > >::m_size.
|
inline |
Add an element to the top of the stack.
If size() is equal to the capacity (set in the constructor or in resize()), effects are undefined. resize() is not called implicitly.
val | The element to add. |
Definition at line 62 of file internal_stack.h.
References tpie::internal_stack_vector_base< T, internal_stack< T > >::m_elements, and tpie::internal_stack_vector_base< T, internal_stack< T > >::m_size.
|
inlineinherited |
Change the capacity of the structure and clear all elements.
size | New capacity of the structure. |
Definition at line 77 of file internal_stack_vector_base.h.
References tpie::internal_stack_vector_base< T, child_t >::m_elements, tpie::internal_stack_vector_base< T, child_t >::m_size, tpie::array< T, Allocator >::resize(), and tpie::internal_stack_vector_base< T, child_t >::size().
|
inlineinherited |
Return the number of elements in the data structure.
Definition at line 87 of file internal_stack_vector_base.h.
References tpie::internal_stack_vector_base< T, child_t >::m_size.
|
inline |
Return the topmost element on the stack.
Definition at line 53 of file internal_stack.h.
References tpie::internal_stack_vector_base< T, internal_stack< T > >::m_elements, and tpie::internal_stack_vector_base< T, internal_stack< T > >::m_size.
|
protectedinherited |
Element storage.
Definition at line 41 of file internal_stack_vector_base.h.
Referenced by tpie::internal_stack< T >::push(), and tpie::internal_stack< T >::top().
|
protectedinherited |
Number of elements pushed to the structure.
Definition at line 44 of file internal_stack_vector_base.h.
Referenced by tpie::internal_stack< T >::pop(), tpie::internal_stack< T >::push(), and tpie::internal_stack< T >::top().