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

# ACE_Unbounded_Stack Class Template Reference

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

`#include <Containers_T.h>`

Collaboration diagram for ACE_Unbounded_Stack:

[legend]
List of all members.

## Public Types
typedef ACE_Unbounded_Stack_Iterator< T > | ITERATOR
## Public Methods
| ACE_Unbounded_Stack (ACE_Allocator *alloc=0)
| Initialize an empty stack using the user specified allocation strategy if provided. More...
| ACE_Unbounded_Stack (const ACE_Unbounded_Stack< T > &s)
| Initialize this stack to be an exact copy of <s>. More...
void | operator= (const ACE_Unbounded_Stack< T > &s)
| Perform a deep copy of the rhs into the lhs. More...
| ~ACE_Unbounded_Stack (void)
| Destroy the underlying list for the stack. More...
int | push (const T &new_item)
| Place a new item on top of the stack. More...
int | pop (T &item)
| Remove and return the top stack item. More...
int | top (T &item) const
| Return top stack item without removing it. More...
int | is_empty (void) const
| Constant time check to see if the stack is empty. More...
int | is_full (void) const
| Always resturns 0 since the stack is unbounded. More...
int | insert (const T &new_item)
| Insert <new_item> into the Stack at the head (but doesn't allow duplicates). More...
int | remove (const T &item)
| Linear remove operation. More...
int | find (const T &item) const
| Linear find operation. More...
size_t | size (void) const
| Constant time access to the current stack size. 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 Methods
void | delete_all_nodes (void)
| Delete all the nodes in the stack. More...
void | copy_all_nodes (const ACE_Unbounded_Stack< T > &s)
| Copy all nodes from <s> to <this>. More...
## Private Attributes
ACE_Node< T > * | head_
| Head of the linked list of Nodes. More...
size_t | cur_size_
| Current size of the stack. More...
ACE_Allocator * | allocator_
| Allocation strategy of the stack. More...
## Friends
class | ACE_Unbounded_Stack_Iterator< T >

## Detailed Description

### template<class T>
class ACE_Unbounded_Stack< T >

Implement a generic LIFO abstract data type.

This implementation of an unbounded Stack uses a linked list. If you use the <insert> or <remove> methods you should keep in mind that duplicate entries aren't allowed. In general, therefore, you should avoid the use of these methods since they aren't really part of the ADT stack. The stack is implemented as a doubly linked list.

Requirements and Performance Characteristics

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

## Member Typedef Documentation

template<class T>
typedef ACE_Unbounded_Stack_Iterator<T> ACE_Unbounded_Stack::ITERATOR

## Constructor & Destructor Documentation

template<class T>
ACE_Unbounded_Stack< T >::ACE_Unbounded_Stack | ( | ACE_Allocator * | alloc = 0 | ) |

| Initialize an empty stack using the user specified allocation strategy if provided.

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

| Initialize this stack to be an exact copy of <s>.

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

| Destroy the underlying list for the stack.

## Member Function Documentation

template<class T>
void ACE_Unbounded_Stack< T >::copy_all_nodes | ( | const ACE_Unbounded_Stack< T > & | s | ) | `[private]`

| Copy all nodes from <s> to <this>.

template<class T>
void ACE_Unbounded_Stack< T >::delete_all_nodes | ( | void |  | ) | `[private]`

| Delete all the nodes in the stack.

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

| Dump the state of an object.

template<class T>
int ACE_Unbounded_Stack< T >::find | ( | const T & | item | ) | const

| Linear find operation.

template<class T>
int ACE_Unbounded_Stack< T >::insert | ( | const T & | item | ) |

| Insert <new_item> into the Stack at the head (but doesn't allow duplicates). Returns -1 if failures occur, 1 if item is already present (i.e., no duplicates are allowed), else 0.

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

| Constant time check to see if the stack is empty.

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

| Always resturns 0 since the stack is unbounded.

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

| Perform a deep copy of the rhs into the lhs.

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

| 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>
int ACE_Unbounded_Stack< T >::push | ( | const T & | new_item | ) |

| 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>
int ACE_Unbounded_Stack< T >::remove | ( | const T & | item | ) |

| Linear remove operation.

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

| Constant time access to the current stack size.

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

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

## Friends And Related Function Documentation

template<class T>
friend class ACE_Unbounded_Stack_Iterator< T >`[friend]`

## Member Data Documentation

template<class T>
ACE_Unbounded_Stack::ACE_ALLOC_HOOK_DECLARE

| Declare the dynamic allocation hooks.

template<class T>
ACE_Allocator* ACE_Unbounded_Stack::allocator_`[private]`

| Allocation strategy of the stack.

template<class T>
size_t ACE_Unbounded_Stack::cur_size_`[private]`

| Current size of the stack.

template<class T>
ACE_Node<T>* ACE_Unbounded_Stack::head_`[private]`

| Head of the linked list of Nodes.

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

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