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 |
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 194 of file stack.h.
References tpie::unused().
|
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 362 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 340 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 249 of file stack.h.
References PERSIST_PERSISTENT, and tpie::temp_file::set_persistent().
|
inline |
Returns the persistence status of the (stream underlying the) stack.
Definition at line 257 of file stack.h.
References tpie::temp_file::is_persistent(), PERSIST_DELETE, and PERSIST_PERSISTENT.
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 318 of file stack.h.
References tpie::ami::END_OF_STREAM, tpie::ami::IO_ERROR, and tpie::ami::NO_ERROR.
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 299 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 233 of file stack.h.
Referenced by tpie::ami::stack< T >::stream_len().
|
inline |
Definition at line 283 of file stack.h.
References tpie::ami::stack< T >::size().
|
inline |
Truncates the underlying stream to the exact size (rounded up to the next block) of items.
In the current implementation, this does nothing.
Definition at line 266 of file stack.h.
References tpie::ami::NO_ERROR.