Class: RedBlackTree

Class RedBlackTree |
In: | rbtree.rb
Parent: | Object

     RedBlackTree

An ordered tree object. Items put into this tree must be Comparable (<=>). This class mixes in Enumerable, and optimized versions of min and max are supplied. All other Enumerable methods are unoptimized, and performance for these may be worse than an Array. min() and max() are only optimized for the default case (IE, no supplied block). Note that these limitations are due to the fact that this is an ordered tree, and any attempt to perform operations on the tree that can not take advantage of this order will suffer.

Methods

<< add each max max_depth_of min new path_to search traverse

Attributes

:root | [R] |

Classes and Modules

Class RedBlackTree::Node

Included modules

Enumerable

Public Class methods

new()

Public Instance methods

<<(object)

A synonym for add()

add(object)

Adds a Comparable object to this tree

each() {|item.value unless item.nil?| ...}

yields for each item in the tree

search(value) {|curr.value if block_given?| ...}

Finds an object in the tree. If a block is provided, it will be yielded to with each node that is touched on the way to the item.

path_to(value)

Finds a path to a given value, as an array of nodes leading to the item.

min(&block)

max()

traverse(object=@root) {|node, count| ...}

max_depth_of(child)