class CB::Types::TreeNode(T)

Included Modules

Defined in:

types/tree.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(value : T, children = [] of TreeNode(T)) #

[View source]

Instance Method Detail

def <<(node : TreeNode(T)) #

[View source]
def <<(arr : Array) #

[View source]
def <<(value : T) #

[View source]
def children : Array(TreeNode(T)) #

[View source]
def children=(children : Array(TreeNode(T))) #

[View source]
def each(&block : Tuple(TreeNode(T), Int32) -> ) #
Description copied from module Enumerable({CB::Types::TreeNode(T), Int32})

Must yield this collection's elements to the block.


[View source]
def each_value(&block : T -> ) #

[View source]
def find(&block : T -> Bool) #
Description copied from module Enumerable({CB::Types::TreeNode(T), Int32})

Returns the first element in the collection for which the passed block is truthy.

Accepts an optional parameter if_none, to set what gets returned if no element is found (defaults to nil).

[1, 2, 3, 4].find { |i| i > 2 }     # => 3
[1, 2, 3, 4].find { |i| i > 8 }     # => nil
[1, 2, 3, 4].find(-1) { |i| i > 8 } # => -1

[View source]
def has_children? #

[View source]
def last_child? #

[View source]
def parent : TreeNode(T) | Nil #

[View source]
def parent=(parent : TreeNode(T) | Nil) #

[View source]
def value : T #

[View source]
def value=(value : T) #

[View source]