text cover

Data Abstraction and Problem Solving with C++

Walls and Mirrors

by Frank M. Carrano

Addison Wesley Logo

Heap Class Reference

#include <Heap.h>

List of all members.


Detailed Description

ADT heap.

Definition at line 26 of file Heap.h.

Public Member Functions

 Heap ()
virtual ~Heap ()
virtual bool heapIsEmpty () const
virtual void heapInsert (const HeapItemType &newItem) throw (HeapException)
virtual void heapDelete (HeapItemType &rootItem) throw (HeapException)

Protected Member Functions

void heapRebuild (int root)

Private Attributes

HeapItemType items [MAX_HEAP]
int size


Constructor & Destructor Documentation

Heap::Heap  ) 
 

Definition at line 19 of file Heap.cpp.

Heap::~Heap  )  [virtual]
 

Default constructor.

Definition at line 23 of file Heap.cpp.


Member Function Documentation

bool Heap::heapIsEmpty  )  const [virtual]
 

Determines whether a heap is empty.

Precondition:
None.
Postcondition:
None.
Returns:
True if the heap is empty; otherwise returns false.

Definition at line 27 of file Heap.cpp.

References size.

Referenced by PriorityQueue::pqIsEmpty().

void Heap::heapInsert const HeapItemType newItem  )  throw (HeapException) [virtual]
 

Inserts an item into a heap.

Precondition:
newItem is the item to be inserted.
Postcondition:
If the heap was not full, newItem is in its proper position.
Exceptions:
HeapException If the heap is full.

Definition at line 32 of file Heap.cpp.

References MAX_HEAP.

void Heap::heapDelete HeapItemType rootItem  )  throw (HeapException) [virtual]
 

Retrieves and deletes the item in the root of a heap. This item has the largest search key in the heap.

Precondition:
None.
Postcondition:
If the heap was not empty, rootItem is the retrieved item, the item is deleted from the heap.
Exceptions:
HeapException If the heap is empty.

Definition at line 60 of file Heap.cpp.

void Heap::heapRebuild int  root  )  [protected]
 

Converts the semiheap rooted at index root into a heap.

Definition at line 74 of file Heap.cpp.

References items, and size.


Member Data Documentation

HeapItemType Heap::items[MAX_HEAP] [private]
 

Definition at line 64 of file Heap.h.

Referenced by heapRebuild().

int Heap::size [private]
 

Array of heap items.

Definition at line 65 of file Heap.h.

Referenced by heapIsEmpty(), and heapRebuild().


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

Generated on Sun Aug 27 22:03:32 2006 for AWLogo by  doxygen 1.4.6