- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Mers::Utils::Containers::StackTemplate< Data > Class Template Reference

`#include <DynamicStackTemplate.h>`

Inheritance diagram for Mers::Utils::Containers::StackTemplate< Data >:

[legend]
Collaboration diagram for Mers::Utils::Containers::StackTemplate< Data >:

[legend]
List of all members.

## Public Types
typedef Data | value_type
typedef Data & | reference
typedef const Data & | const_reference
typedef Data * | pointer
typedef const Data * | const_pointer
typedef StackTemplate< Data > | ContainerType
typedef IteratorTemplate< const_pointer, ContainerType > | const_iterator
typedef IteratorTemplate< pointer, ContainerType > | iterator
typedef const_iterator | ConstantIterator
typedef iterator | Iterator
## Public Member Functions
| StackTemplate (bool myOwnershipStatus)
virtual | ~StackTemplate ()
iterator | begin ()
const_iterator | begin () const
iterator | end ()
const_iterator | end () const
virtual int | push (pointer data)
virtual pointer | pop ()
virtual bool | empty () const
virtual unsigned int | size () const
virtual reference | top ()
virtual const_reference | top () const
virtual void | clear ()
pointer & | operator[] (int elementIndex)
pointer & | operator[] (unsigned int elementIndex)
const_pointer | operator[] (int elementIndex) const
const_pointer | operator[] (unsigned int elementIndex) const
## Protected Member Functions
void | printElement (std::ostream &out, void const *element) const
void | deleteElement (void *element) const
void * | newElement (void const *element) const
bool | isEqual (void const *element1, void const *element2) const
## Friends
std::ostream & | operator<< (std::ostream &out, const ContainerType &other)

## Detailed Description

### template<class Data>
class Mers::Utils::Containers::StackTemplate< Data >

Implements the generic template class for a stack.

Definition at line 28 of file DynamicStackTemplate.h.

## Constructor & Destructor Documentation

template<class Data>

Mers::Utils::Containers::StackTemplate< Data >::StackTemplate | ( | bool | myOwnershipStatus | ) | `[inline]`

Creates a new, empty array

Definition at line 42 of file DynamicStackTemplate.h.

template<class Data>

virtual Mers::Utils::Containers::StackTemplate< Data >::~StackTemplate | ( |  | ) | `[inline, virtual]`

Destroys the array

Definition at line 55 of file DynamicStackTemplate.h.

References Mers::Utils::Containers::DynamicArray::makeEmpty().

Here is the call graph for this function:

## Member Function Documentation

template<class Data>

iterator Mers::Utils::Containers::StackTemplate< Data >::begin | ( |  | ) | `[inline]`

returns a iterator that points to the first element of this array

Returns:
  a iterator that starts this object

Definition at line 80 of file DynamicStackTemplate.h.

template<class Data>

const_iterator Mers::Utils::Containers::StackTemplate< Data >::begin | ( |  | ) | const`[inline]`

returns a constant iterator that points to the first element of this array

Returns:
  a constant iterator that starts this object

Definition at line 90 of file DynamicStackTemplate.h.

template<class Data>

iterator Mers::Utils::Containers::StackTemplate< Data >::end | ( |  | ) | `[inline]`

returns a iterator that points just past the last element of this array

Returns:
  a iterator that ends this object

Definition at line 101 of file DynamicStackTemplate.h.

References Mers::Utils::Containers::DynamicArray::getLength().

Here is the call graph for this function:

template<class Data>

const_iterator Mers::Utils::Containers::StackTemplate< Data >::end | ( |  | ) | const`[inline]`

returns a constant iterator that points just past the last element of this array

Returns:
  a constant iterator that ends this object

Definition at line 111 of file DynamicStackTemplate.h.

References Mers::Utils::Containers::DynamicArray::getLength().

Here is the call graph for this function:

template<class Data>

virtual int Mers::Utils::Containers::StackTemplate< Data >::push | ( | pointer | data | ) | `[inline, virtual]`

Adds a data element to the top of the stack, allocating space if necessary for it to fit. This object assumes ownership of data object and will delete it when this object is destroyed, if the appropriate ownership flag is set.

Parameters:

  | data | pointer to the data being added

Returns:
  0 on success or a positive number if the data could not be added

Definition at line 128 of file DynamicStackTemplate.h.

References Mers::Utils::Containers::DynamicArray::pushBack().

Here is the call graph for this function:

template<class Data>

virtual pointer Mers::Utils::Containers::StackTemplate< Data >::pop | ( |  | ) | `[inline, virtual]`

Returns the last element of the array and removes it from the array, also reduces the size of the array should it fall below 1/4 full. The caller is now responsible for whatever memory was returned.

Returns:
  the data element at the end of the current array

Definition at line 141 of file DynamicStackTemplate.h.

References Mers::Utils::Containers::DynamicArray::popBack().

Here is the call graph for this function:

template<class Data>

virtual bool Mers::Utils::Containers::StackTemplate< Data >::empty | ( |  | ) | const`[inline, virtual]`

Returns true if this stack is empty.

Definition at line 149 of file DynamicStackTemplate.h.

References Mers::Utils::Containers::DynamicArray::isEmpty().

Here is the call graph for this function:

template<class Data>

virtual unsigned int Mers::Utils::Containers::StackTemplate< Data >::size | ( |  | ) | const`[inline, virtual]`

Returns the number of elements in the stack.

Reimplemented from Mers::Utils::Containers::DynamicArray.

Definition at line 156 of file DynamicStackTemplate.h.

References Mers::Utils::Containers::DynamicArray::getLength().

Here is the call graph for this function:

template<class Data>

virtual reference Mers::Utils::Containers::StackTemplate< Data >::top | ( |  | ) | `[inline, virtual]`

Returns a modifiable reference to the top of the stack.

Definition at line 163 of file DynamicStackTemplate.h.

References Mers::Utils::Containers::DynamicArray::peekBack().

Here is the call graph for this function:

template<class Data>

virtual const_reference Mers::Utils::Containers::StackTemplate< Data >::top | ( |  | ) | const`[inline, virtual]`

Returns a modifiable reference to the top of the stack.

Definition at line 170 of file DynamicStackTemplate.h.

References Mers::Utils::Containers::DynamicArray::peekBack().

Here is the call graph for this function:

template<class Data>

virtual void Mers::Utils::Containers::StackTemplate< Data >::clear | ( |  | ) | `[inline, virtual]`

Clears (either discarding or deleting) all of the members of this stack. The particulars are determined by the ownership flag.

Definition at line 179 of file DynamicStackTemplate.h.

References Mers::Utils::Containers::DynamicArray::makeEmpty().

Here is the call graph for this function:

template<class Data>

pointer& Mers::Utils::Containers::StackTemplate< Data >::operator[] | ( | int | elementIndex | ) | `[inline]`

retrieves the element at the specified index and returns it

Parameters:

  | elementIndex | location of the element to be accessed

Returns:
  the element requested if index is in range, otherwise it returns NULL

Reimplemented from Mers::Utils::Containers::DynamicArray.

Definition at line 194 of file DynamicStackTemplate.h.

References Mers::Utils::Containers::DynamicArray::operator[]().

Here is the call graph for this function:

template<class Data>

pointer& Mers::Utils::Containers::StackTemplate< Data >::operator[] | ( | unsigned int | elementIndex | ) | `[inline]`

retrieves the element at the specified index and returns it

Parameters:

  | elementIndex | location of the element to be accessed

Returns:
  the element requested if index is in range, otherwise it returns NULL

Reimplemented from Mers::Utils::Containers::DynamicArray.

Definition at line 205 of file DynamicStackTemplate.h.

References Mers::Utils::Containers::DynamicArray::operator[]().

Here is the call graph for this function:

template<class Data>

const_pointer Mers::Utils::Containers::StackTemplate< Data >::operator[] | ( | int | elementIndex | ) | const`[inline]`

retrieves the element at the specified index and returns it

Parameters:

  | elementIndex | location of the element to be accessed

Returns:
  the element requested if index is in range, otherwise it returns NULL

Reimplemented from Mers::Utils::Containers::DynamicArray.

Definition at line 216 of file DynamicStackTemplate.h.

References Mers::Utils::Containers::DynamicArray::operator[]().

Here is the call graph for this function:

template<class Data>

const_pointer Mers::Utils::Containers::StackTemplate< Data >::operator[] | ( | unsigned int | elementIndex | ) | const`[inline]`

retrieves the element at the specified index and returns it

Parameters:

  | elementIndex | location of the element to be accessed

Returns:
  the element requested if index is in range, otherwise it returns NULL

Reimplemented from Mers::Utils::Containers::DynamicArray.

Definition at line 227 of file DynamicStackTemplate.h.

References Mers::Utils::Containers::DynamicArray::operator[]().

Here is the call graph for this function:

template<class Data>

void Mers::Utils::Containers::StackTemplate< Data >::printElement | ( | std::ostream & | out,
|  | void const * | element |
| ) |  |  | const`[inline, protected, virtual]`

Prints the element of this array to the ostream out. This is called by the DynamicArray::operator<< for each element being printed

Parameters:

  | out | the stream being printed to
  | element | the element being printed

Implements Mers::Utils::Containers::DynamicArray.

Definition at line 270 of file DynamicStackTemplate.h.

template<class Data>

void Mers::Utils::Containers::StackTemplate< Data >::deleteElement | ( | void * | element | ) | const`[inline, protected, virtual]`

Called when an element should be deleted because it's storage space is being deleted. This function deletes the element (Data).

Parameters:

  | element | the BaesModelAssignment to delete

Implements Mers::Utils::Containers::DynamicArray.

Definition at line 285 of file DynamicStackTemplate.h.

template<class Data>

void* Mers::Utils::Containers::StackTemplate< Data >::newElement | ( | void const * | element | ) | const`[inline, protected, virtual]`

Creates and returns a new Data that is a copy of the Data element.

Parameters:

  | element | the element being copied

Returns:
  the new Data object that is a copy of element

Implements Mers::Utils::Containers::DynamicArray.

Definition at line 297 of file DynamicStackTemplate.h.

template<class Data>

bool Mers::Utils::Containers::StackTemplate< Data >::isEqual | ( | void const * | element1,
|  | void const * | element2 |
| ) |  |  | const`[inline, protected, virtual]`

returns true if the two elements are equal. This default function returns true if the pointers are the same.

Parameters:

  | element1 | the first element in the comparison
  | element2 | the second element in the comparison

Returns:
  true if they are the equal and false if they are not equal

Reimplemented from Mers::Utils::Containers::DynamicArray.

Definition at line 309 of file DynamicStackTemplate.h.

## Friends And Related Function Documentation

template<class Data>

std::ostream& operator<< | ( | std::ostream & | out,
|  | const ContainerType & | other |
| ) |  |  | `[friend]`

Prints out this object to the ostream out by calling its print() routine

Parameters:

  | out | the ostream being written to
  | other | the BaseModelObject being printed

Returns:
  the out ostream

Definition at line 243 of file DynamicStackTemplate.h.

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

- /Users/fpy/titan-1-5-MBARI/Mers/Utils/Containers/DynamicStackTemplate.h