ROSE 0.11.145.147
|
Stack-based container.
The stack stores values in a last-in-first-out order. New items are pushed onto the top of the stack and existing items are popped from the top of the stack.
#include <Sawyer/Stack.h>
Public Types | |
typedef T | Value |
Public Member Functions | |
Stack () | |
Construct an empty stack. | |
template<class Iterator > | |
Stack (const boost::iterator_range< Iterator > &range) | |
Construct a stack from an iterator range. | |
size_t | size () const |
Returns the number of items on the stack. | |
bool | isEmpty () const |
Determines if the stack is empty. | |
Stack & | push (const Value &value) |
Push new item onto stack. | |
Value | pop () |
Pop existing item from stack. | |
Value & | top () |
Returns the top item. | |
const Value & | top () const |
Returns the top item. | |
Value & | get (size_t idx) |
Access an item not at the top of the stack. | |
const Value & | get (size_t idx) const |
Access an item not at the top of the stack. | |
Value & | operator[] (size_t idx) |
Access an item not at the top of the stack. | |
const Value & | operator[] (size_t idx) const |
Access an item not at the top of the stack. | |
typedef T Sawyer::Container::Stack< T >::Value |
|
inline |
|
inline |
Construct a stack from an iterator range.
Definition at line 33 of file Stack.h.
References Sawyer::Container::IndexedList< T, Alloc >::pushBack().
|
inline |
Returns the number of items on the stack.
Definition at line 41 of file Stack.h.
References Sawyer::Container::IndexedList< T, Alloc >::size().
Referenced by Sawyer::Container::Stack< T >::get(), and Sawyer::Container::Stack< T >::get().
|
inline |
Determines if the stack is empty.
Returns true if the stack is empty, false if not empty.
Definition at line 48 of file Stack.h.
References Sawyer::Container::IndexedList< T, Alloc >::isEmpty().
Referenced by Sawyer::Container::Stack< T >::top(), and Sawyer::Container::Stack< T >::top().
|
inline |
Returns the top item.
Returns a reference to the top item of the stack. The stack must not be empty.
Definition at line 57 of file Stack.h.
References Sawyer::Container::IndexedList< T, Alloc >::backValue(), and Sawyer::Container::Stack< T >::isEmpty().
Referenced by Sawyer::Container::Stack< T >::pop().
|
inline |
Returns the top item.
Returns a reference to the top item of the stack. The stack must not be empty.
Definition at line 61 of file Stack.h.
References Sawyer::Container::IndexedList< T, Alloc >::backValue(), and Sawyer::Container::Stack< T >::isEmpty().
|
inline |
Access an item not at the top of the stack.
Returns a reference to the indicated item. Item zero is the top of the stack, item one is the next item below the top, etc. The stack must not be empty, and idx
must be less than the size of the stack.
Definition at line 73 of file Stack.h.
References Sawyer::Container::IndexedList< T, Alloc >::size(), and Sawyer::Container::Stack< T >::size().
Referenced by Sawyer::Container::Stack< T >::operator[](), and Sawyer::Container::Stack< T >::operator[]().
|
inline |
Access an item not at the top of the stack.
Returns a reference to the indicated item. Item zero is the top of the stack, item one is the next item below the top, etc. The stack must not be empty, and idx
must be less than the size of the stack.
Definition at line 77 of file Stack.h.
References Sawyer::Container::IndexedList< T, Alloc >::size(), and Sawyer::Container::Stack< T >::size().
|
inline |
Access an item not at the top of the stack.
Returns a reference to the indicated item. Item zero is the top of the stack, item one is the next item below the top, etc. The stack must not be empty, and idx
must be less than the size of the stack.
Definition at line 81 of file Stack.h.
References Sawyer::Container::Stack< T >::get().
|
inline |
Access an item not at the top of the stack.
Returns a reference to the indicated item. Item zero is the top of the stack, item one is the next item below the top, etc. The stack must not be empty, and idx
must be less than the size of the stack.
Definition at line 82 of file Stack.h.
References Sawyer::Container::Stack< T >::get().
|
inline |
Push new item onto stack.
Copies the specified item onto the top of the stack, making the stack one element larger. The stack itself is returned so that this method can be chained.
Definition at line 89 of file Stack.h.
References Sawyer::Container::IndexedList< T, Alloc >::pushBack().
|
inline |
Pop existing item from stack.
Copies the top item from the stack and returns it, then reduces the size of the stack by one element. The stack must not be empty at the time this method is called.
Definition at line 98 of file Stack.h.
References Sawyer::Container::IndexedList< T, Alloc >::erase(), Sawyer::Container::IndexedList< T, Alloc >::size(), and Sawyer::Container::Stack< T >::top().