ACE_Unbounded_Stack< T > Class Template Reference

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

#include <Containers_T.h>

Collaboration diagram for ACE_Unbounded_Stack< T >:

Collaboration graph
[legend]

List of all members.

Public Types

typedef
ACE_Unbounded_Stack_Iterator
< T > 
ITERATOR

Public Member Functions

 ACE_Unbounded_Stack (ACE_Allocator *the_allocator=0)
 ACE_Unbounded_Stack (const ACE_Unbounded_Stack< T > &s)
 The copy constructor (performs initialization).
void operator= (const ACE_Unbounded_Stack< T > &s)
 Assignment operator (performs assignment).
 ~ACE_Unbounded_Stack (void)
 Perform actions needed when stack goes out of scope.
int push (const T &new_item)
 Push an element onto the top of stack.
int pop (T &item)
 Pop the top element of the stack.
int top (T &item) const
 Examine the top of the stack.
int is_empty (void) const
 Returns 1 if the container is empty, otherwise returns 0.
int is_full (void) const
 Returns 1 if the container is full, otherwise returns 0.
int insert (const T &new_item)
 Linear Insert of an item.
int remove (const T &item)
int find (const T &item) const
 Finds if item occurs the set. Returns 0 if finds, else -1.
size_t size (void) const
 The number of items in the stack.
void dump (void) const
 Dump the state of an object.

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.

Private Member Functions

void delete_all_nodes (void)
 Delete all the nodes in the stack.
void copy_all_nodes (const ACE_Unbounded_Stack< T > &s)
 Copy all nodes from {s} to {this}.

Private Attributes

ACE_Node< T > * head_
 Head of the linked list of Nodes.
size_t cur_size_
 Current size of the stack.
ACE_Allocatorallocator_
 Allocation strategy of the stack.

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


Member Typedef Documentation

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


Constructor & Destructor Documentation

template<class T>
ACE_Unbounded_Stack< T >::ACE_Unbounded_Stack ( ACE_Allocator the_allocator = 0  )  [inline]

Initialize a new stack so that it is empty. Use user defined allocation strategy if specified. 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  )  [inline]

The copy constructor (performs initialization).

Initialize this stack to be an exact copy of {s}.

template<class T>
ACE_Unbounded_Stack< T >::~ACE_Unbounded_Stack ( void   )  [inline]

Perform actions needed when stack goes out of scope.

Destroy the underlying list for the stack.


Member Function Documentation

template<class T>
void ACE_Unbounded_Stack< T >::operator= ( const ACE_Unbounded_Stack< T > &  s  )  [inline]

Assignment operator (performs assignment).

Perform a deep copy of the rhs into the lhs.

template<class T>
int ACE_Unbounded_Stack< T >::push ( const T &  new_item  )  [inline]

Push an element onto the top of 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>
int ACE_Unbounded_Stack< T >::pop ( T &  item  )  [inline]

Pop the top element of the 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_Unbounded_Stack< T >::top ( T &  item  )  const [inline]

Examine the top of the 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.

template<class T>
ACE_INLINE int ACE_Unbounded_Stack< T >::is_empty ( void   )  const [inline]

Returns 1 if the container is empty, otherwise returns 0.

Constant time check to see if the stack is empty.

template<class T>
ACE_INLINE int ACE_Unbounded_Stack< T >::is_full ( void   )  const [inline]

Returns 1 if the container is full, otherwise returns 0.

Always resturns 0 since the stack is unbounded.

template<class T>
int ACE_Unbounded_Stack< T >::insert ( const T &  new_item  )  [inline]

Linear Insert of an 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>
int ACE_Unbounded_Stack< T >::remove ( const T &  item  )  [inline]

Remove item from the Stack. Returns 0 if it removes the item, -1 if it can't find the item, and -1 if a failure occurs. Linear remove operation.

template<class T>
int ACE_Unbounded_Stack< T >::find ( const T &  item  )  const [inline]

Finds if item occurs the set. Returns 0 if finds, else -1.

Linear find operation.

template<class T>
ACE_INLINE size_t ACE_Unbounded_Stack< T >::size ( void   )  const [inline]

The number of items in the stack.

Constant time access to the current stack size.

template<class T>
void ACE_Unbounded_Stack< T >::dump ( void   )  const [inline]

Dump the state of an object.

template<class T>
void ACE_Unbounded_Stack< T >::delete_all_nodes ( void   )  [inline, private]

Delete all the nodes in the stack.

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

Copy all nodes from {s} to {this}.


Friends And Related Function Documentation

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


Member Data Documentation

Declare the dynamic allocation hooks.

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

Head of the linked list of Nodes.

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

Current size of the stack.

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

Allocation strategy of the stack.


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

Generated on Wed Apr 23 02:42:57 2008 for ACE by  doxygen 1.5.5