feisty meow concerns codebase
2.140
|
An abstraction that represents a stack data structure. More...
#include <stack.h>
Public Types | |
enum | stack_kinds { BOUNDED , UNBOUNDED } |
Public Member Functions | |
stack (int elements=0) | |
Creates a stack with room for the specified number of "elements". More... | |
stack (const stack &to_copy) | |
constructs a stack as a copy of "to_copy". More... | |
~stack () | |
destroys anything left on the stack. More... | |
void | reset () |
throws out all contents on the stack. More... | |
stack_kinds | kind () const |
returns the type of stack that was constructed. More... | |
basis::outcome | push (const contents &element) |
Enters a new element onto the top of the stack. More... | |
basis::outcome | pop () |
Removes the top element on the stack. More... | |
contents & | top () |
Returns the top element from the stack but doesn't change the stack. More... | |
basis::outcome | acquire_pop (contents &to_stuff) |
Used to grab the top off of the stack. More... | |
int | size () const |
returns the size of the stack. More... | |
stack & | operator= (const stack &to_copy) |
makes this stack a copy of "to_copy". More... | |
contents & | operator[] (int index) |
Accesses the item at position "index" in the stack. More... | |
void | invert () |
Inverts this stack, meaning that the old bottom is the new top. More... | |
int | elements () const |
Returns the number of elements used by the stack. More... | |
An abstraction that represents a stack data structure.
This behaves like a standard stack of objects, but it additionally allows access to any item in the stack via an array style bracket operator.
enum structures::stack::stack_kinds |
structures::stack< contents >::stack | ( | int | elements = 0 | ) |
Creates a stack with room for the specified number of "elements".
If "elements" is zero, then the stack is an UNBOUNDED stack that has no set limit on the number of elements it can contain (besides the amount of memory available). on an unbounded stack, a result of IS_FULL will never be returned–instead a memory allocation failure would occur. If "elements" is greater than zero, then the stack is a BOUNDED stack which can hold at maximum "elements" number of objects. for bounded stacks, if there is to be an allocation failure, it will happen at the time of stack construction, rather than during execution.
structures::stack< contents >::stack | ( | const stack< contents > & | to_copy | ) |
constructs a stack as a copy of "to_copy".
Definition at line 120 of file stack.h.
References structures::stack< contents >::operator=().
structures::stack< contents >::~stack |
basis::outcome structures::stack< contents >::acquire_pop | ( | contents & | to_stuff | ) |
Used to grab the top off of the stack.
this is basically a call to top() followed by a pop(). if there was no top, then IS_EMPTY is returned.
Definition at line 196 of file stack.h.
Referenced by nodes::packable_tree::recursive_unpack(), and nodes::tree::~tree().
int structures::stack< contents >::elements |
Returns the number of elements used by the stack.
For a bounded stack, this returns the number of elements the stack was constructed to hold. For an unbounded stack, it returns the current number of elements (which is the same as size()). Note though that it is different from size() for a bounded size stack!
void structures::stack< contents >::invert |
|
inline |
returns the type of stack that was constructed.
Definition at line 54 of file stack.h.
Referenced by configuration::variable_tokenizer::parse().
stack< contents > & structures::stack< contents >::operator= | ( | const stack< contents > & | to_copy | ) |
makes this stack a copy of "to_copy".
Definition at line 165 of file stack.h.
Referenced by structures::stack< contents >::stack().
contents & structures::stack< contents >::operator[] | ( | int | index | ) |
Accesses the item at position "index" in the stack.
Allows access to the stack in an impure fashion; elements other than the top can be examined. Efforts to access elements that do not exist are ignored. The range for the element numbers is as in C and runs from 0 to size() - 1.
basis::outcome structures::stack< contents >::pop |
Removes the top element on the stack.
If the stack has no elements to be popped off, then IS_EMPTY is returned. The element that was popped is destroyed.
Definition at line 151 of file stack.h.
Referenced by configuration::variable_tokenizer::parse().
basis::outcome structures::stack< contents >::push | ( | const contents & | element | ) |
Enters a new element onto the top of the stack.
if the stack is too large to add another element, then IS_FULL is returned. if the element to push is nil, the stack is unchanged and IS_EMPTY is returned.
Definition at line 139 of file stack.h.
Referenced by configuration::variable_tokenizer::parse(), nodes::packable_tree::recursive_unpack(), and nodes::tree::~tree().
void structures::stack< contents >::reset |
int structures::stack< contents >::size |
returns the size of the stack.
if the stack is empty, then 0 is returned.
Definition at line 127 of file stack.h.
Referenced by configuration::variable_tokenizer::parse(), nodes::packable_tree::recursive_unpack(), and nodes::tree::~tree().
contents & structures::stack< contents >::top |
Returns the top element from the stack but doesn't change the stack.
This method does not pop the element! If the stack is empty, then a bogus contents object is returned.
Definition at line 161 of file stack.h.
Referenced by configuration::variable_tokenizer::parse().