module BinaryTree(T, Node, NilNode)
Included Modules
- Enumerable(T)
- Iterable(T)
Direct including types
Defined in:
datastructure/binary_tree.crInstance Method Summary
- #<<(key : T) : self
- #add(key : T) : self
- #add?(key : T) : Bool
- #clear : self
- #delete(key : T) : Bool
-
#each(node : Node = min_node)
Must return an
Iteratorover the elements in this collection. -
#each(node : Node = min_node, &) : Nil
Must yield this collection's elements to the block.
- #empty? : Bool
- #ge(key : T) : T?
- #ge!(key : T) : T
- #ge_node(key : T, x : Node = root) : Node
- #gt(key : T) : T?
- #gt!(key : T) : T
- #gt_node(key : T, x : Node = root) : Node
- #includes?(key : T) : Bool
- #le(key : T) : T?
- #le!(key : T) : T
- #le_node(key : T, x : Node = root) : Node
- #lt(key : T) : T?
- #lt!(key : T) : T
- #lt_node(key : T, x : Node = root) : Node
-
#max : T
Returns the element with the maximum value in the collection.
-
#max? : T?
Like
#maxbut returnsnilif the collection is empty. - #max_node : Node
-
#min : T
Returns the element with the minimum value in the collection.
-
#min? : T?
Like
#minbut returnsnilif the collection is empty. - #min_node : Node
- #reverse_each(node : Node = max_node)
- #reverse_each(node : Node = max_node, &) : Nil
- #root
- #rotate_left(x : Node) : Nil
- #rotate_right(x : Node) : Nil
- #search(key : T, x : Node = root) : Node
-
#size : Int32
Returns the number of elements in the collection.
Instance methods inherited from module Enumerable(T)
accumulate(init : U) : Array(U) forall Uaccumulate : Array(T)
accumulate(init : U, &block : U, T -> U) : Array(U) forall U
accumulate(&block : T, T -> T) : Array(T) accumulate, mex : T mex, mex_sorted : T mex_sorted, tally(*, default : Int32) : Hash(T, Int32) tally, unique : self
unique(&) : self unique
Instance Method Detail
Must return an Iterator over the elements in this collection.
Must yield this collection's elements to the block.
Returns the element with the maximum value in the collection.
It compares using > so it will work for any type that supports that method.
[1, 2, 3].max # => 3
["Alice", "Bob"].max # => "Bob"
Raises Enumerable::EmptyError if the collection is empty.
Like #max but returns nil if the collection is empty.
Returns the element with the minimum value in the collection.
It compares using < so it will work for any type that supports that method.
[1, 2, 3].min # => 1
["Alice", "Bob"].min # => "Alice"
Raises Enumerable::EmptyError if the collection is empty.
Like #min but returns nil if the collection is empty.
Returns the number of elements in the collection.
[1, 2, 3, 4].size # => 4