Reference

ACE_Bounded_Stack(3)

Implement a generic LIFO abstract data type.

NAME

ACE_Bounded_Stack - Implement a generic LIFO abstract data type.

SYNOPSIS

#include <ace/Containers.h>
template<class T>
class ACE_Bounded_Stack
{
  public:
    ACE_Bounded_Stack (size_t size);
    ACE_Bounded_Stack (const ACE_Bounded_Stack<T> &s);
    void operator= (const ACE_Bounded_Stack<T> &s);
    ~ACE_Bounded_Stack (void);
    int push (const T &new_item);
    int pop (T &item);
    int top (T &item) const;
    int is_empty (void) const;
    int is_full (void) const;
    size_t size (void) const;
    void dump (void) const;
    ACE_ALLOC_HOOK_DECLARE;
  private:
    size_t size_;
    size_t top_;
    T *stack_;
};

DESCRIPTION

This implementation of a Stack uses a bounded array that is allocated dynamically.

Initialization, assignemnt, and termination methods.

ACE_Bounded_Stack (size_t size);

Initialize a new stack so that it is empty.

ACE_Bounded_Stack (const ACE_Bounded_Stack<T> &s);

The copy constructor (performs initialization).

void operator= (const ACE_Bounded_Stack<T> &s);

Assignment operator (performs assignment).

~ACE_Bounded_Stack (void);

Perform actions needed when stack goes out of scope.

Classic Stack operations.

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

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

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

Check boundary conditions.

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.

size_t size (void) const;

The number of items in the stack.

void dump (void) const;

Dump the state of an object.

ACE_ALLOC_HOOK_DECLARE;

Declare the dynamic allocation hooks.

AUTHOR

Doug Schmidt

Initialization and termination methods.

Check boundary conditions.

Classic unordered set operations.

LIBRARY

ace