BFLibCPP 0.1
CPP Library
|
#include <bintree.hpp>
Classes | |
class | BinNode |
class | Iterator |
Public Member Functions | |
BinTree () | |
virtual | ~BinTree () |
virtual const BinNode * | root () const |
void | setCompareCallback (int(*cb)(T a, T b)) |
int | insert (T obj) |
S | count () const |
bool | contains (T obj) |
virtual void | print () |
T | max () const |
T | min () const |
virtual const BinNode * | minNode () const |
virtual const BinNode * | maxNode () const |
virtual int | remove (T obj) |
virtual int | deleteNode (BinNode *node) |
int | removeAll () |
int | leafValues (List< T > *list) |
virtual int | createIterator (Iterator **itr) |
virtual const BinNode * | getNodeForObject (T obj) |
int | runCompare (T a, T b) const |
![]() | |
Object () | |
Object (Object &obj) | |
virtual | ~Object () |
Protected Member Functions | |
BinNode * | getNodeForObject (T obj, BinNode *node) |
BinNode ** | rootAddr () |
Root accessors. | |
void | setRoot (BinNode *node) |
virtual BinNode * | root () |
virtual void * | createNode () |
BinNode ** | getNodeLocation (const BinNode *node) |
void | setNodeLocation (BinNode *node, BinNode **location) |
BinNode * | getNodeParent (const BinNode *node) |
void | setNodeParent (BinNode *node, BinNode *parent) |
virtual int | insert (BinNode *newNode, BinNode *parent) |
virtual bool | canNewNodeTakeNewLocation (BinNode **newLocation) |
virtual int | replaceNodeWithTheOnlyChild (BinNode *node) |
virtual int | replaceNodeWithNode (BinNode *node, BinNode *replacement) |
int | removeNode (BinNode *node) |
virtual void | print (BinNode *node) |
virtual const BinNode * | maxNode (const BinNode *node) const |
Returns the leaf node | |
virtual const BinNode * | minNode (const BinNode *node) const |
Returns the leaf node | |
Protected Attributes | |
S | _count |
Additional Inherited Members | |
![]() | |
static void | retain (Object *obj) |
static void | release (Object *obj) |
static int | retainCount (Object *obj) |
static int | retainCount (Object &obj) |
Standard Binary Tree
Left most node is the least value comparison
|
inline |
|
inlinevirtual |
|
inlineprotectedvirtual |
|
inline |
Sees if obj is inside our tree start from root
|
inline |
|
inlinevirtual |
Caller owns memory to the iterator
After you have traversed through all nodes, the iterator becomes stale. To reiterate, you must ask us to create one again
|
inlineprotectedvirtual |
Creates BinNode
Derived classes must override to submit their own node
|
inlinevirtual |
Removes node from tree and deletes it from memory
|
inlinevirtual |
Returns nonnull pointer to BinNode
Returns NULL if node with obj could not be found
Caller does not own node
Reimplemented in BF::RBTree< T, S >, BF::RBTree< BF::Dictionary::Entry *, int >, and BF::RBTree< BF::Dictionary::Entry *, S >.
|
inlineprotected |
Returns nonnull pointer to BinNode
Returns NULL if node with obj could not be found
TODO: remove recursion
|
inlineprotected |
|
inlineprotected |
|
inlineprotectedvirtual |
Inserts newNode into parent's children
newNode should already have an obj set. Otherwise there will be undefined behavior
Sets newNode's location field
|
inline |
Inserts object into tree
|
inline |
Makes a list of all leaf node values
Returns nonzero upon error
|
inline |
|
inlinevirtual |
Reimplemented in BF::RBTree< T, S >, BF::RBTree< BF::Dictionary::Entry *, int >, and BF::RBTree< BF::Dictionary::Entry *, S >.
|
inlineprotectedvirtual |
Returns the leaf node
|
inline |
|
inlinevirtual |
Reimplemented in BF::RBTree< T, S >, BF::RBTree< BF::Dictionary::Entry *, int >, and BF::RBTree< BF::Dictionary::Entry *, S >.
|
inlineprotectedvirtual |
Returns the leaf node
|
inlinevirtual |
Prints tree with root at the left most positions and the leafs at the right most, start from the top the right leaves
Reimplemented in BF::RBTree< T, S >, BF::RBTree< BF::Dictionary::Entry *, int >, and BF::RBTree< BF::Dictionary::Entry *, S >.
|
inlineprotectedvirtual |
|
inlinevirtual |
Removes the node that has the object
Reimplemented in BF::RBTree< T, S >, BF::RBTree< BF::Dictionary::Entry *, int >, and BF::RBTree< BF::Dictionary::Entry *, S >.
|
inline |
Deletes everything in the tree
|
inlineprotected |
Performs standard BST Deletion
|
inlineprotectedvirtual |
This node's children will not be exchanged. The replacement's children will be retained. Additionally, the replacement's parent will no longer have any reference to node
Use insert logic to place the children in correctly
|
inlineprotectedvirtual |
Replaces node with its child
We assume node only has one kid
|
inlineprotectedvirtual |
|
inlinevirtual |
Reimplemented in BF::RBTree< T, S >, BF::RBTree< BF::Dictionary::Entry *, int >, and BF::RBTree< BF::Dictionary::Entry *, S >.
|
inlineprotected |
Root accessors.
|
inline |
If the _compare function pointer was not set, then we will default by comparing its literal value
0xFFFFFFFF returned if comparison errored
a == b -> 0 a < b -> ret < 0 a > b -> ret > 0
|
inline |
Optional but will help with sorting tree
if not set, we will compare a and b literally
Please set your own comparison if a and b are some other object
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
protected |
Holds size of tree