An implementation of an external-memory stack compatible with the old AMI interface. More...
#include <tpie/stack.h>
Public Member Functions | |
| stack () | |
| Initializes the stack. More... | |
| stack (const std::string &path, stream_type type=READ_WRITE_STREAM) | |
| Initializes the stack by (re-)opening the file given. More... | |
| err | push (const T &t) |
| Pushes one item onto the stack. More... | |
| err | pop (const T **t) |
| Pops one item from the stack. More... | |
| err | peek (const T **t) |
| Peeks at the topmost item on the stack. More... | |
| TPIE_OS_OFFSET | size () const |
| Returns the number of items currently on the stack. More... | |
| bool | is_empty () const |
| Returns whether the stack is empty or not. More... | |
| void | persist (persistence p) |
| Set the persistence status of the (stream underlying the) stack. More... | |
| persistence | persist () const |
| Returns the persistence status of the (stream underlying the) stack. More... | |
| err | trim () |
| Truncates the underlying stream to the exact size (rounded up to the next block) of items. More... | |
| err | main_memory_usage (TPIE_OS_SIZE_T *usage, stream_usage usage_type) const |
| Compute the memory used by the stack and the aggregated stream. More... | |
| TPIE_OS_OFFSET | stream_len () const |
| tpie::stack< T > & | underlying_stack () |
An implementation of an external-memory stack compatible with the old AMI interface.
|
inline |
|
inline |
Initializes the stack by (re-)opening the file given.
| path | The path to a file used for storing the items. |
| type | An stream_type that indicates the read/write mode of the file. |
Definition at line 198 of file stack.h.
|
inline |
| err tpie::ami::stack< T >::main_memory_usage | ( | TPIE_OS_SIZE_T * | usage, |
| stream_usage | usage_type | ||
| ) | const |
Compute the memory used by the stack and the aggregated stream.
| usage | Where the usage will be stored. |
| usage_type | The type of usage_type inquired from the stream. |
Definition at line 373 of file stack.h.
References tpie::stack< T >::memory_usage(), tpie::ami::NO_ERROR, tpie::STREAM_USAGE_BUFFER, tpie::STREAM_USAGE_CURRENT, tpie::STREAM_USAGE_MAXIMUM, tpie::STREAM_USAGE_OVERHEAD, tpie::STREAM_USAGE_SUBSTREAM, and tp_assert.
| err tpie::ami::stack< T >::peek | ( | const T ** | t | ) |
Peeks at the topmost item on the stack.
Returns ERROR_* as given by the underlying stream or END_OF_STREAM if the stack is empty.
| t | A pointer to a pointer that will point to the topmost item. |
Definition at line 349 of file stack.h.
References tpie::ami::END_OF_STREAM, tpie::ami::IO_ERROR, and tpie::ami::NO_ERROR.
|
inline |
Set the persistence status of the (stream underlying the) stack.
| p | A persistence status. |
Definition at line 253 of file stack.h.
|
inline |
Returns the persistence status of the (stream underlying the) stack.
Definition at line 261 of file stack.h.
| err tpie::ami::stack< T >::pop | ( | const T ** | t | ) |
Pops one item from the stack.
Returns ERROR_* as given by the underlying stream or END_OF_STREAM if the stack is empty.
| t | A pointer to a pointer that will point to the topmost item. |
Definition at line 325 of file stack.h.
References tpie::ami::END_OF_STREAM, tpie::ami::IO_ERROR, and tpie::ami::NO_ERROR.
Referenced by tpie::pipelining::bits::ami_input_stack_t< dest_t >::go().
| err tpie::ami::stack< T >::push | ( | const T & | t | ) |
Pushes one item onto the stack.
Returns ERROR_* as given by the underlying stream.
| t | The item to be pushed onto the stack. |
Definition at line 306 of file stack.h.
References tpie::ami::END_OF_STREAM, tpie::ami::IO_ERROR, and tpie::ami::NO_ERROR.
|
inline |
Returns the number of items currently on the stack.
Definition at line 237 of file stack.h.
Referenced by tpie::pipelining::bits::ami_input_stack_t< dest_t >::propagate(), tpie::pipelining::bits::ami_pull_input_stack_t< T >::propagate(), and tpie::ami::stack< item_type >::stream_len().
|
inline |
Definition at line 287 of file stack.h.
|
inline |
Truncates the underlying stream to the exact size (rounded up to the next block) of items.
In the current implementation, this does nothing.