ROSE  0.11.96.11
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.
 
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. 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...
 

Member Function Documentation

◆ isEmpty()

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().

Here is the caller graph for this function:

◆ top() [1/2]

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().

Here is the caller graph for this function:

◆ top() [2/2]

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.

◆ get() [1/2]

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.

Referenced by Sawyer::Container::Stack< size_t >::operator[]().

Here is the caller graph for this function:

◆ get() [2/2]

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.

◆ operator[]() [1/2]

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.

◆ operator[]() [2/2]

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.

◆ push()

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.

◆ pop()

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: