#include <AbstractHeap.h>
Public Methods | |
| AbstractHeap (const char *nameBuff="Unnamed", int initSize=defaultSize, int quantumChoice=defaultQuantum) | |
| Constructor, which allows the heap to be named. | |
| virtual | ~AbstractHeap () |
| Destructor. | |
| bool | empty () const |
Returns true if the list is empty and false otherwise. | |
| operator bool () const | |
Returns true if the list is empty and false otherwise. | |
| int | size () const |
| Returns the number of items in the heap. | |
| OrderSense | sense () |
Return the value of Sense. | |
| void | setSense (OrderSense sense_) |
Set the value of Sense. | |
| T * | top () const |
| Return the top of the heap. | |
| T * | member (int element) const |
| Return a specific element of the heap. | |
| T * | find (KEY &key) |
| Find the element with the given key. More... | |
| virtual void | add (KEY &key) |
| Add a key to the heap. | |
| virtual void | add (KEY &key, T *&item) |
| Add a key to the heap and return the heap item that contains it. | |
| virtual void | remove (KEY &key, bool &status) |
| Remove a heap item with the given key. More... | |
| virtual void | remove (T *&item, bool &status) |
| Remove a heap item. More... | |
| virtual void | remove (T *&item, KEY &key, bool &status) |
| Remove a heap and return the item's key. More... | |
| int | write (ostream &os) const |
| Write the heap to an output stream. | |
| int | read (istream &is) |
| Read a heap from an input stream. | |
| int | prune () |
| TODO. | |
| void | clear () |
| Empty the heap. | |
Static Public Attributes | |
| const int | defaultSize = 256 |
| Default size of the heap. | |
| const int | defaultQuantum = 256 |
| The default quantum used to resize the heap. | |
Protected Methods | |
| virtual T * | insert (KEY *item) |
| Add an item to the heap. | |
| virtual void | extract (T *item, bool &status) |
| Remove a heap item. More... | |
| int | refloatElement (int element) |
| TODO. | |
| virtual int | prunable (T *) |
| TODO. | |
| virtual void | moveEffect (T *) |
| TODO. | |
| virtual void | addEffect (T *) |
| TODO. | |
| virtual void | removeEffect (T *item) |
| TODO. | |
| virtual void | pruneEffect (T *) |
| TODO. | |
| void | swap (int a, int b) |
| TODO. | |
| int | floatUp (int element) |
| TODO. | |
| int | sinkDown (int element) |
| TODO. | |
Protected Attributes | |
| OrderSense | Sense |
| Specifies the ordering within the tree: increasing or decreasing. | |
| int | used |
| The number of items in the heap. | |
| int | allocated |
The size of the tree array. | |
| int | quantum |
The quantity by which the tree array is increased. | |
| T ** | tree |
| The array that contains the heap. | |
| const char * | name |
| The name of the heap. | |
This class is based on a generic heap class initially develop by Jonathan Eckstein (Rutgers).
TODO: evaluate how this class relates to the STL heap class.
|
||||||||||||||||
|
Remove a heap item.
The status flag is |
|
||||||||||
|
Find the element with the given key. Returns null if no such key exists. |
|
||||||||||||||||||||
|
Remove a heap and return the item's key.
The status flag is |
|
||||||||||||||||
|
Remove a heap item.
The status flag is |
|
||||||||||||||||
|
Remove a heap item with the given key.
The status flag is |