Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages

# ACE_Bounded_Stack Class Template Reference

Implement a generic LIFO abstract data type. More...

`#include <Containers_T.h>`

Collaboration diagram for ACE_Bounded_Stack:

[legend]
List of all members.

## Public Methods
| ACE_Bounded_Stack (size_t size)
| Initialize a new empty stack with the provided size.. More...
| ACE_Bounded_Stack (const ACE_Bounded_Stack< T > &s)
| Initialize the stack to be a copy of the stack provided. More...
void | operator= (const ACE_Bounded_Stack< T > &s)
| Assignment operator. More...
| ~ACE_Bounded_Stack (void)
| Perform actions needed when stack goes out of scope. More...
int | push (const T &new_item)
| Add an element to the top of the stack. More...
int | pop (T &item)
| Remove an item from the top of stack. More...
int | top (T &item) const
| Examine the contents of the top of stack. More...
int | is_empty (void) const
| Returns 1 if the container is empty, otherwise returns 0. More...
int | is_full (void) const
| Returns 1 if the container is full, otherwise returns 0. More...
size_t | size (void) const
| The number of items in the stack. More...
void | dump (void) const
| Dump the state of an object. More...
## Public Attributes
| ACE_ALLOC_HOOK_DECLARE
| Declare the dynamic allocation hooks. More...
## Private Attributes
size_t | size_
| Size of the dynamically allocated data. More...
size_t | top_
| Keeps track of the current top of stack. More...
T * | stack_
| Holds the stack's contents. More...

## Detailed Description

### template<class T>
class ACE_Bounded_Stack< T >

Implement a generic LIFO abstract data type.

This implementation of a Stack uses a bounded array that is allocated dynamically. The Stack interface provides the standard constant time push, pop, and top operations.

Requirements and Performance Characteristics

- Internal Structure Dynamic array
- Duplicates allowed? Yes
- Random access allowed? No
- Search speed N/A
- Insert/replace speed N/A
- Iterator still valid after change to container? N/A
- Frees memory for removed elements? No
- Items inserted by Value
- Requirements for contained type
  1. Default constructor
  2. Copy constructor
  3. operator=

## Constructor & Destructor Documentation

template<class T>
ACE_Bounded_Stack< T >::ACE_Bounded_Stack | ( | size_t | size | ) |

| Initialize a new empty stack with the provided size.. Initialize and allocate space for a new Bounded_Stack with the provided size.

template<class T>
ACE_Bounded_Stack< T >::ACE_Bounded_Stack | ( | const ACE_Bounded_Stack< T > & | s | ) |

| Initialize the stack to be a copy of the stack provided. Initialize the stack to be an exact copy of the Bounded_Stack provided as a parameter.

template<class T>
ACE_Bounded_Stack< T >::~ACE_Bounded_Stack | ( | void |  | ) |

| Perform actions needed when stack goes out of scope. Deallocate the memory used by the Bounded_Stack.

## Member Function Documentation

template<class T>
void ACE_Bounded_Stack< T >::dump | ( | void |  | ) | const

| Dump the state of an object.

template<class T>
ACE_INLINE int ACE_Bounded_Stack< T >::is_empty | ( | void |  | ) | const

| Returns 1 if the container is empty, otherwise returns 0. Performs constant time check to determine if the stack is empty.

template<class T>
ACE_INLINE int ACE_Bounded_Stack< T >::is_full | ( | void |  | ) | const

| Returns 1 if the container is full, otherwise returns 0. Performs constant time check to determine if the stack is at capacity.

template<class T>
void ACE_Bounded_Stack< T >::operator= | ( | const ACE_Bounded_Stack< T > & | s | ) |

| Assignment operator. Perform a deep copy operation using the Bounded_Stack parameter. If the capacity of the lhs isn't sufficient for the rhs, then the underlying data structure will be reallocated to accomadate the larger number of elements.

template<class T>
ACE_INLINE int ACE_Bounded_Stack< T >::pop | ( | T & | item | ) |

| Remove an item from the top of stack. Remove and return the top stack item. Returns -1 if the stack is already empty, 0 if the stack is not already empty, and -1 if failure occurs.

template<class T>
ACE_INLINE int ACE_Bounded_Stack< T >::push | ( | const T & | new_item | ) |

| Add an element to the top of the stack. Place a new item on top of the stack. Returns -1 if the stack is already full, 0 if the stack is not already full, and -1 if failure occurs.

template<class T>
ACE_INLINE size_t ACE_Bounded_Stack< T >::size | ( | void |  | ) | const

| The number of items in the stack. Return the number of items currently in the stack.

template<class T>
ACE_INLINE int ACE_Bounded_Stack< T >::top | ( | T & | item | ) | const

| Examine the contents of the top of stack. Return top stack item without removing it. Returns -1 if the stack is already empty, 0 if the stack is not already empty, and -1 if failure occurs.

## Member Data Documentation

template<class T>
ACE_Bounded_Stack::ACE_ALLOC_HOOK_DECLARE

| Declare the dynamic allocation hooks.

template<class T>
size_t ACE_Bounded_Stack::size_`[private]`

| Size of the dynamically allocated data.

template<class T>
T* ACE_Bounded_Stack::stack_`[private]`

| Holds the stack's contents.

template<class T>
size_t ACE_Bounded_Stack::top_`[private]`

| Keeps track of the current top of stack.

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

- Containers_T.h
- Containers_T.cpp
- Containers_T.i