ABA_BSTACK< Type > Class Template Reference

a set of elements, following the last-in first-out (LIFO) principle the access to or the deletion of an element is restricted to the most recently inserted element. More...

#include <bstack.h>

Inheritance diagram for ABA_BSTACK< Type >:

ABA_ABACUSROOT List of all members.

Public Member Functions

 ABA_BSTACK (ABA_GLOBAL *glob, int size)
int size () const
int tos () const
bool empty () const
bool full () const
void push (Type item)
Type top () const
Type pop ()
 Accesses like top() the last element pushed on the stack and removes in addition this item from the stack.
void realloc (int newSize)

Private Attributes

ABA_GLOBALglob_
ABA_ARRAY< Type > stack_
int tos_

Friends

ostream & operator<< (ostream &out, const ABA_BSTACK< Type > &rhs)
 The output operator writes the numbers of all stacked elements and the elements line by line on an output stream.

Detailed Description

template<class Type>
class ABA_BSTACK< Type >

a set of elements, following the last-in first-out (LIFO) principle the access to or the deletion of an element is restricted to the most recently inserted element.

Definition at line 56 of file bstack.h.


Constructor & Destructor Documentation

template<class Type>
ABA_BSTACK< Type >::ABA_BSTACK ( ABA_GLOBAL glob,
int  size 
)

The constructor initializes an empty stack.

Parameters:
glob A pointer to the corresponding global object.
size The maximal number of elements the stack can store.


Member Function Documentation

template<class Type>
int ABA_BSTACK< Type >::size (  )  const

Returns:
The maximal number of elements which can be inserted into the stack.

template<class Type>
int ABA_BSTACK< Type >::tos (  )  const

Returns:
The top of the stack, i.e., the number of the next free component of the stack. This is also the number of elements currently contained in the stack since the first element is inserted in position 0.

template<class Type>
bool ABA_BSTACK< Type >::empty (  )  const

Returns:
true If there is no element in the stack,

false otherwise.

template<class Type>
bool ABA_BSTACK< Type >::full (  )  const

Returns:
true If the maximal number of elements has been inserted in the stack,

false otherwise.

template<class Type>
void ABA_BSTACK< Type >::push ( Type  item  ) 

Adds an element to the stack.

It is a fatal error to insert an element if the stack is full. If this function is compiled with -DABACUSSAFE, then the program terminates if this error occurs.

Parameters:
item The element added to the stack.

template<class Type>
Type ABA_BSTACK< Type >::top (  )  const

Accesses the last element pushed on the stack without removing it.

It is an error to perform this operation on an empty stack. If this function is compiled with -DABACUSSAFE, then the program terminates if this error occurs.

Returns:
The last element pushed on the stack.

template<class Type>
Type ABA_BSTACK< Type >::pop (  ) 

Accesses like top() the last element pushed on the stack and removes in addition this item from the stack.

It is an error to perform this operation on an empty stack. If this function is compiled with -DABACUSSAFE, then the program terminates if this error occurs.

Returns:
The last element pushed on the stack.

template<class Type>
void ABA_BSTACK< Type >::realloc ( int  newSize  ) 

Changes the maximal number of elements of the stack.

Parameters:
newSize The new maximal number of elements on the stack. If newSize is less than the current number of elements in the stack, then the newSize oldest element are contained in the stack after the reallocation.


Friends And Related Function Documentation

template<class Type>
ostream& operator<< ( ostream &  out,
const ABA_BSTACK< Type > &  rhs 
) [friend]

The output operator writes the numbers of all stacked elements and the elements line by line on an output stream.

Returns:
A reference to the output stream.
Parameters:
out The output stream.
rhs The stack being output.


Member Data Documentation

template<class Type>
ABA_GLOBAL* ABA_BSTACK< Type >::glob_ [private]

A pointer to the corresponding global object.

Definition at line 157 of file bstack.h.

template<class Type>
ABA_ARRAY<Type> ABA_BSTACK< Type >::stack_ [private]

The array storing the elements of the stack.

Definition at line 161 of file bstack.h.

template<class Type>
int ABA_BSTACK< Type >::tos_ [private]

The top of stack (next free component).

Definition at line 165 of file bstack.h.


The documentation for this class was generated from the following file:
Generated on Tue Aug 14 18:09:56 2007 for ABACUS by  doxygen 1.5.1