ROSE  0.9.9.149
Public Types | Public Member Functions | List of all members
Sawyer::Container::Stack< T > Class Template Reference

Description

template<typename T>
class Sawyer::Container::Stack< T >

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.

Definition at line 22 of file Stack.h.

#include <Stack.h>

Inheritance diagram for Sawyer::Container::Stack< T >:
Inheritance graph
[legend]

Public Types

typedef T Value
 

Public Member Functions

 Stack ()
 Construct an empty stack. More...
 
template<class Iterator >
 Stack (const boost::iterator_range< Iterator > &range)
 Construct a stack from an iterator range. More...
 
size_t size () const
 Returns the number of items on the stack. More...
 
bool isEmpty () const
 Determines if the stack is empty. More...
 
Stackpush (const Value &value)
 Push new item onto stack. More...
 
Value pop ()
 Pop existing item from stack. More...
 
Value & top ()
 Returns the top item. More...
 
const Value & top () const
 Returns the top item. More...
 
Value & get (size_t idx)
 Access an item not at the top of the stack. More...
 
const Value & get (size_t idx) const
 Access an item not at the top of the stack. More...
 
Value & operator[] (size_t idx)
 Access an item not at the top of the stack. More...
 
const Value & operator[] (size_t idx) const
 Access an item not at the top of the stack. More...
 

Constructor & Destructor Documentation

template<typename T>
Sawyer::Container::Stack< T >::Stack ( )
inline

Construct an empty stack.

Definition at line 29 of file Stack.h.

template<typename T>
template<class Iterator >
Sawyer::Container::Stack< T >::Stack ( const boost::iterator_range< Iterator > &  range)
inline

Construct a stack from an iterator range.

Definition at line 33 of file Stack.h.

Member Function Documentation

template<typename T>
size_t Sawyer::Container::Stack< T >::size ( void  ) const
inline

Returns the number of items on the stack.

Definition at line 41 of file Stack.h.

Referenced by Sawyer::Container::Stack< size_t >::get().

template<typename T>
bool Sawyer::Container::Stack< T >::isEmpty ( ) const
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.

Referenced by Sawyer::Container::Stack< size_t >::top().

template<typename T>
Value& 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.

Referenced by Sawyer::Container::Stack< size_t >::pop().

template<typename T>
const Value& Sawyer::Container::Stack< T >::top ( ) const
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.

template<typename T>
Value& Sawyer::Container::Stack< T >::get ( size_t  idx)
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.

template<typename T>
const Value& Sawyer::Container::Stack< T >::get ( size_t  idx) const
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.

template<typename T>
Value& Sawyer::Container::Stack< T >::operator[] ( size_t  idx)
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.

template<typename T>
const Value& Sawyer::Container::Stack< T >::operator[] ( size_t  idx) const
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.

template<typename T>
Stack& Sawyer::Container::Stack< T >::push ( const Value &  value)
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.

template<typename T>
Value Sawyer::Container::Stack< T >::pop ( )
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.


The documentation for this class was generated from the following file: