binary_tree |
class BinaryTree < Object |
Constants |
| Node | A Node is an element in a BinaryTree. It has 4 members: left, right, parent, and value. |
|---|
Public Methods |
length is an alias for size.
Create a new BinaryTree
Clear all the elements from the tree.
Insert an element into the tree, on the left side of node.
| parent | the parent of the new node. |
|---|---|
| value | the value of the new node. |
Returns: the node that was inserted
Insert an element into the tree, on the left side of node.
| parent | the parent of the new node. |
|---|---|
| value | the value of the new node. |
Returns: the node that was inserted
Insert an element into the tree, on the left side of node.
| left | the left node of the new root. |
|---|---|
| right | the right node of the new root. |
| value | the value of the new root. |
Returns: the new root.
Delete a node from the tree. The children must be re-inserted into the tree.
Returns: 1 if the node was the right child, -1 if the node was the left child, and 0 if the node was the root
Iterate through all the elements in the BinaryTree, in order.
Returns: the last value from yield.
each_pair is an alias for each.
Iterate through all the elements in the BinaryTree, in order.
Returns: the last value from yield.
reverse_each_pair is an alias for reverse_each.
Determine whether a BinaryTree is empty.
Returns: true if the BinaryTree has no elements, false otherwise
Mixins |
| Enumerable | |
|---|---|
| EnumerableContainer | |
| PairEnumerableContainer |
Protected Methods |