text cover

Data Abstraction and Problem Solving with C++

Walls and Mirrors

by Frank M. Carrano

Addison Wesley Logo

Stack Class Reference

#include <StackA.h>

List of all members.


Detailed Description

ADT stack - Array-based implementation.

Definition at line 23 of file StackA.h.

Public Member Functions

 Stack ()
bool isEmpty () const
void push (const StackItemType &newItem) throw (StackException)
void pop () throw (StackException)
void pop (StackItemType &stackTop) throw (StackException)
void getTop (StackItemType &stackTop) const throw (StackException)

Private Attributes

StackItemType items [MAX_STACK]
int top


Constructor & Destructor Documentation

Stack::Stack  ) 
 

Default constructor.

Definition at line 19 of file StackA.cpp.


Member Function Documentation

bool Stack::isEmpty  )  const
 

Determines whether this stack is empty.

Precondition:
None.
Postcondition:
None.
Returns:
True if this stack is empty; otherwise returns false.

Definition at line 23 of file StackA.cpp.

References top.

Referenced by pop().

void Stack::push const StackItemType newItem  )  throw (StackException)
 

Adds an item to the top of this stack.

Precondition:
newItem is the item to be added.
Postcondition:
If the insertion is successful, newItem is on the top of this stack.
Parameters:
newItem The given StackItemType.
Exceptions:
StackException If the item cannot be placed on this stack.

Definition at line 28 of file StackA.cpp.

References MAX_STACK.

Referenced by main().

void Stack::pop  )  throw (StackException)
 

Removes the top of this stack.

Precondition:
None.
Postcondition:
If this stack is not empty, the item that was added most recently is removed. However, if this stack is empty, deletion is impossible.
Exceptions:
StackException If this stack is empty.

Definition at line 40 of file StackA.cpp.

References isEmpty(), and top.

void Stack::pop StackItemType stackTop  )  throw (StackException)
 

Retrieves and removes the top of this stack.

Precondition:
None.
Postcondition:
If this stack is not empty, stackTop contains the item that was added most recently and the item is removed. However, if this stack is empty, deletion is impossible and stackTop is unchanged.
Exceptions:
StackException If this stack is empty.

Definition at line 48 of file StackA.cpp.

void Stack::getTop StackItemType stackTop  )  const throw (StackException)
 

Retrieves the top of this stack.

Precondition:
None.
Postcondition:
If this stack is not empty, stackTop contains the item that was added most recently. However, if this stack is empty, the operation fails and stackTop is unchanged. This stack is unchanged.
Exceptions:
StackException If this stack is empty.

Definition at line 59 of file StackA.cpp.


Member Data Documentation

StackItemType Stack::items[MAX_STACK] [private]
 

Array of stack items

Definition at line 78 of file StackA.h.

int Stack::top [private]
 

Index to top of stack

Definition at line 80 of file StackA.h.

Referenced by isEmpty(), and pop().


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

Generated on Sun Aug 27 16:41:11 2006 for AWLogo by  doxygen 1.4.6