gtkIOStream
1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
|
#include <HeapTreeType.H>
Public Member Functions | |
HeapTreeType (int baseIn=2) | |
Constructor - currrently only supports baseIn=2 : to be expanded in the future. More... | |
void | add (HT_TYPE value) |
void | findCell (unsigned int index, HeapTreeCell &cell) |
void | findCell (HT_TYPE *index, HeapTreeCell &cell) |
unsigned int | findIndex (HeapTreeCell &cell) |
unsigned int | findParent (unsigned int index) |
void | findChildren (unsigned int parent, HeapTreeCell &childL, HeapTreeCell &childR) |
void | dump () |
void | dumpDereference () |
void | dumpLPR (HeapTreeCell &cell) |
void | sort (void) |
void | resize (size_t s, HT_TYPE c=HT_TYPE()) |
virtual void | deleteElements (void) |
Protected Member Functions | |
void | swap (unsigned int one, unsigned int two) |
Protected Attributes | |
int | unsortedCount |
Private Member Functions | |
void | swapIfBigger (unsigned int index) |
Private Attributes | |
float | base |
HeapTreeType for constant variables Implementation of a min. HeapTreeType with an included sort method. It obeys the following properties : shape property: the tree is a complete binary tree; that is, all levels of the tree, except possibly the last one (deepest) are fully filled, and, if the last level of the tree is not complete, the nodes of that level are filled from left to right. heap property: each node is greater than or equal to each of its children according to a comparison predicate.
Whilst this HeapTreeType inherits from vector, certain operators can not be exposed to the user, consequently inheritance is protected.
A concept for expansion to non-binary heap trees is sought in the future, it is currently not supported.
A simplistic '<' is used for comparison and it is assumed that the HT_TYPE is capable of being compared in this way, e.g. when HT_TYPE in int.
HT_TYPE | the type of the HeapTreeType |
Definition at line 67 of file HeapTreeType.H.
|
inline |
Constructor - currrently only supports baseIn=2 : to be expanded in the future.
Definition at line 118 of file HeapTreeType.H.
|
inline |
HeapTreeType add, which ensures that both shape and heap properties are satisfied.
value | The variable to add. |
Definition at line 127 of file HeapTreeType.H.
|
inlinevirtual |
Delete reset the unsortedCount
Reimplemented in HeapTree< HT_TYPE >.
Definition at line 265 of file HeapTreeType.H.
|
inline |
Run through the vector and output (to cout) the HT_TYPE tree element.
Definition at line 218 of file HeapTreeType.H.
|
inline |
Run through the vector and output (to cout) the HT_TYPE tree element.
Definition at line 225 of file HeapTreeType.H.
|
inline |
Given a cell, dump to cout the children.
Definition at line 232 of file HeapTreeType.H.
|
inline |
Completes a cell, which instructs the layer and location within the layer of the HT_TYPE element at index.
index | [in] The HT_TYPE element vector index to find the HeapTreeCell representation of. |
cell | [out] The resulting 'tree co-ordinates' of the element at vectorial index. |
Definition at line 151 of file HeapTreeType.H.
|
inline |
Given an element, find the 'tree co-ordinate' location and store in cell
[in] | index | The element to located the tree co-ordinates of |
[out] | cell | The resulting 'tree co-ordinates' of the element at vectorial index. |
Definition at line 159 of file HeapTreeType.H.
|
inline |
Given a parent's vector index, return the children't 'tree co-ordinatees'
parent | The parent's vector index. |
childL | The left child's level and level index. |
childR | The right child's level and level index. |
Definition at line 202 of file HeapTreeType.H.
|
inline |
Given 'tree co-ordinates', return the vector index.
cell | Tree co-ordinates. The level and level index of the tree element. |
Definition at line 176 of file HeapTreeType.H.
|
inline |
Given a child's index, return the parent's index.
index | The child's index |
Definition at line 185 of file HeapTreeType.H.
|
inline |
Calls the vector<HT_TYPE>::resize method.
Definition at line 259 of file HeapTreeType.H.
|
inline |
Sort a HeapTreeType using the sort algorithm.
Definition at line 245 of file HeapTreeType.H.
|
inlineprotected |
Swap two elements in the heap tree.
one | The index of the one to swap with two. |
two | The index of the two to swap with one. |
Definition at line 110 of file HeapTreeType.H.
|
inlineprivate |
Swaps the parent with it's children. If the parent evaluates to be bigger then it's child, then swap the parent and child. If both children are smaller, find the smallest child and swap with the parent.
index | The index of the parent for evaluation. |
Definition at line 75 of file HeapTreeType.H.
|
private |
Definition at line 68 of file HeapTreeType.H.
|
protected |
Definition at line 104 of file HeapTreeType.H.
GTK+ IOStream
Beta
|