BinarySearchTree

Implements a mostly @nogc-able container format, with relatively fast access times. Mostly based upon the AVT tree algorithm with small modifications, with the intent to replace D's default associative arrays for GC-free operations. TODO: Implement ordered tree traversal.

Members

Functions

collectNodes
BSTNode!(K, E)*[] collectNodes(BSTNode!(K, E)* source)
Undocumented in source. Be warned that the author may not have intended to support it.
findMax
BSTNode!(K, E)* findMax()
Undocumented in source. Be warned that the author may not have intended to support it.
findMax
BSTNode!(K, E)* findMax(BSTNode!(K, E)* from)
Undocumented in source. Be warned that the author may not have intended to support it.
findMin
BSTNode!(K, E)* findMin()
Undocumented in source. Be warned that the author may not have intended to support it.
findMin
BSTNode!(K, E)* findMin(BSTNode!(K, E)* from)
Undocumented in source. Be warned that the author may not have intended to support it.
insertAt
bool insertAt(BSTNode!(K, E)** node, K key, E val)

Inserts an item at the given point. Returns true if the height of the tree have been raised.

opApply
int opApply(int delegate(ref E) dg)

Tree traversal for quick access. TODO: Make it NOGC

opIndex
E opIndex(K key)

Gets an element without allocation. Returns E.init if key not found.

opIndexAssign
E opIndexAssign(E value, K i)

Inserts a new element with some automatic optimization. TODO: Make the optimization better.

optimize
void optimize(BSTNode!(K, E)** node)

Optimizes a BinarySearchTree by distributing nodes evenly.

rebalanceTree
void rebalanceTree()

Rebalances a tree.

rebalanceTree
void rebalanceTree(BSTNode!(K, E)** node)
Undocumented in source. Be warned that the author may not have intended to support it.
remove
void remove(K key)

Removes an element by key.

rotateLeft
void rotateLeft(BSTNode!(K, E)** node)

Rotates the subtree to the left by one.

rotateLeftRight
void rotateLeftRight(BSTNode!(K, E)** node)

Rotates the subtree to the right then to the left.

rotateRight
void rotateRight(BSTNode!(K, E)** node)

Rotates the subtree to the right by one.

rotateRightLeft
void rotateRightLeft(BSTNode!(K, E)** node)

Rotates the subtree to the right then to the left.

toString
string toString()
Undocumented in source. Be warned that the author may not have intended to support it.
treeTraversalByDepth
int treeTraversalByDepth(int delegate(ref E) dg, BSTNode!(K, E)* root)
Undocumented in source. Be warned that the author may not have intended to support it.

Properties

length
size_t length [@property getter]

Returns the number of elements in the tree.

Meta