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

ACE_Fixed_Stack Class Template Reference

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

#include <Containers_T.h>

Collaboration diagram for ACE_Fixed_Stack:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_Fixed_Stack (void)
 Initialize a new stack so that it is empty. More...

 ACE_Fixed_Stack (const ACE_Fixed_Stack< T, ACE_SIZE > &s)
 The copy constructor (performs initialization). More...

void operator= (const ACE_Fixed_Stack< T, ACE_SIZE > &s)
 Assignment operator (performs assignment). More...

 ~ACE_Fixed_Stack (void)
 Perform actions needed when stack goes out of scope. More...

int push (const T &new_item)
 Constant time placement of element on top of stack. More...

int pop (T &item)
 Constant time removal of top of stack. More...

int top (T &item) const
 Constant time examination of 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 allocated data. More...

size_t top_
 Keeps track of the current top of stack. More...

stack_ [ACE_SIZE]
 Holds the stack's contents. More...


Detailed Description

template<class T, size_t ACE_SIZE>
class ACE_Fixed_Stack< T, ACE_SIZE >

Implement a generic LIFO abstract data type.

This implementation of a Stack uses a fixed array with the size fixed at instantiation time.

Requirements and Performance Characteristics

Definition at line 207 of file Containers_T.h.


Constructor & Destructor Documentation

template<class T, size_t ACE_SIZE>
ACE_Fixed_Stack< T, ACE_SIZE >::ACE_Fixed_Stack void   
 

Initialize a new stack so that it is empty.

Initialize an empty stack.

Definition at line 92 of file Containers_T.cpp.

References ACE_TRACE.

00093   : size_ (ACE_SIZE),
00094     top_ (0)
00095 {
00096   ACE_TRACE ("ACE_Fixed_Stack<T, ACE_SIZE>::ACE_Fixed_Stack");
00097 }

template<class T, size_t ACE_SIZE>
ACE_Fixed_Stack< T, ACE_SIZE >::ACE_Fixed_Stack const ACE_Fixed_Stack< T, ACE_SIZE > &    s
 

The copy constructor (performs initialization).

Initialize the stack and copy the provided stack into the current stack.

Definition at line 100 of file Containers_T.cpp.

References ACE_TRACE, stack_, and top_.

00101   : size_ (s.size_),
00102     top_ (s.top_)
00103 {
00104   ACE_TRACE ("ACE_Fixed_Stack<T, ACE_SIZE>::ACE_Fixed_Stack");
00105   for (size_t i = 0; i < this->top_; i++)
00106     this->stack_[i] = s.stack_[i];
00107 }

template<class T, size_t ACE_SIZE>
ACE_Fixed_Stack< T, ACE_SIZE >::~ACE_Fixed_Stack void   
 

Perform actions needed when stack goes out of scope.

Destroy the stack.

Definition at line 124 of file Containers_T.cpp.

References ACE_TRACE.

00125 {
00126   ACE_TRACE ("ACE_Fixed_Stack<T, ACE_SIZE>::~ACE_Fixed_Stack");
00127 }


Member Function Documentation

template<class T, size_t ACE_SIZE>
void ACE_Fixed_Stack< T, ACE_SIZE >::dump void    const
 

Dump the state of an object.

Definition at line 86 of file Containers_T.cpp.

References ACE_TRACE.

00087 {
00088   ACE_TRACE ("ACE_Fixed_Stack<T, ACE_SIZE>::dump");
00089 }

template<class T, size_t ACE_SIZE>
ACE_INLINE int ACE_Fixed_Stack< T, ACE_SIZE >::is_empty void    const
 

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

Performs constant time check to see if stack is empty.

Definition at line 68 of file Containers_T.i.

References ACE_TRACE, and top_.

Referenced by pop, and top.

00069 {
00070   ACE_TRACE ("ACE_Fixed_Stack<T, ACE_SIZE>::is_empty");
00071   return this->top_ == 0;
00072 }

template<class T, size_t ACE_SIZE>
ACE_INLINE int ACE_Fixed_Stack< T, ACE_SIZE >::is_full void    const
 

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

Performs constant time check to see if stack is full.

Definition at line 75 of file Containers_T.i.

References ACE_TRACE, size_, and top_.

Referenced by push.

00076 {
00077   ACE_TRACE ("ACE_Fixed_Stack<T, ACE_SIZE>::is_full");
00078   return this->top_ >= this->size_;
00079 }

template<class T, size_t ACE_SIZE>
void ACE_Fixed_Stack< T, ACE_SIZE >::operator= const ACE_Fixed_Stack< T, ACE_SIZE > &    s
 

Assignment operator (performs assignment).

Perform a deep copy of the provided stack.

Definition at line 110 of file Containers_T.cpp.

References ACE_TRACE, stack_, and top_.

00111 {
00112   ACE_TRACE ("ACE_Fixed_Stack<T, ACE_SIZE>::operator=");
00113 
00114   if (&s != this)
00115     {
00116       this->top_ = s.top_;
00117 
00118       for (size_t i = 0; i < this->top_; i++)
00119         this->stack_[i] = s.stack_[i];
00120     }
00121 }

template<class T, size_t ACE_SIZE>
ACE_INLINE int ACE_Fixed_Stack< T, ACE_SIZE >::pop T &    item
 

Constant time removal of 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.

Definition at line 95 of file Containers_T.i.

References ACE_TRACE, is_empty, stack_, and top_.

00096 {
00097   ACE_TRACE ("ACE_Fixed_Stack<T, ACE_SIZE>::pop");
00098   if (this->is_empty () == 0)
00099     {
00100       item = this->stack_[--this->top_];
00101       return 0;
00102     }
00103   else
00104     return -1;
00105 }

template<class T, size_t ACE_SIZE>
ACE_INLINE int ACE_Fixed_Stack< T, ACE_SIZE >::push const T &    new_item
 

Constant time placement of element on 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.

Definition at line 82 of file Containers_T.i.

References ACE_TRACE, is_full, stack_, and top_.

00083 {
00084   ACE_TRACE ("ACE_Fixed_Stack<T, ACE_SIZE>::push");
00085   if (this->is_full () == 0)
00086     {
00087       this->stack_[this->top_++] = new_item;
00088       return 0;
00089     }
00090   else
00091     return -1;
00092 }

template<class T, size_t ACE_SIZE>
ACE_INLINE size_t ACE_Fixed_Stack< T, ACE_SIZE >::size void    const
 

The number of items in the stack.

Constant time access to the current size of the stack.

Definition at line 121 of file Containers_T.i.

References size_.

00122 {
00123   return this->size_;
00124 }

template<class T, size_t ACE_SIZE>
ACE_INLINE int ACE_Fixed_Stack< T, ACE_SIZE >::top T &    item const
 

Constant time examination of 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.

Definition at line 108 of file Containers_T.i.

References ACE_TRACE, is_empty, stack_, and top_.

00109 {
00110   ACE_TRACE ("ACE_Fixed_Stack<T, ACE_SIZE>::top");
00111   if (this->is_empty () == 0)
00112     {
00113       item = this->stack_[this->top_ - 1];
00114       return 0;
00115     }
00116   else
00117     return -1;
00118 }


Member Data Documentation

template<class T, size_t ACE_SIZE>
ACE_Fixed_Stack::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 285 of file Containers_T.h.

template<class T, size_t ACE_SIZE>
size_t ACE_Fixed_Stack::size_ [private]
 

Size of the allocated data.

Definition at line 289 of file Containers_T.h.

Referenced by is_full, and size.

template<class T, size_t ACE_SIZE>
T ACE_Fixed_Stack::stack_[ACE_SIZE] [private]
 

Holds the stack's contents.

Definition at line 295 of file Containers_T.h.

Referenced by ACE_Fixed_Stack, operator=, pop, push, and top.

template<class T, size_t ACE_SIZE>
size_t ACE_Fixed_Stack::top_ [private]
 

Keeps track of the current top of stack.

Definition at line 292 of file Containers_T.h.

Referenced by ACE_Fixed_Stack, is_empty, is_full, operator=, pop, push, and top.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:48:01 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002