class SearchTree::Node

Class that represents a node of a tree data structure

Attributes

nodes[RW]
value[RW]

Public Class Methods

new(value) click to toggle source
# File lib/chess_openings/search_tree.rb, line 145
def initialize(value)
  @value = value
  @nodes = {}
end

Public Instance Methods

==(other) click to toggle source
# File lib/chess_openings/search_tree.rb, line 170
def ==(other)
  return false if size != other.size || @value != other.value
  @nodes.keys.each do |key|
    return false unless other.keys.include?(key)
    return false if @nodes[key] != other.nodes[key]
  end
  true
end
empty?() click to toggle source
# File lib/chess_openings/search_tree.rb, line 150
def empty?
  @value.nil?
end
include?(key) click to toggle source
# File lib/chess_openings/search_tree.rb, line 166
def include?(key)
  @nodes.keys.include?(key)
end
keys() click to toggle source
# File lib/chess_openings/search_tree.rb, line 162
def keys
  @nodes.keys
end
leaf?() click to toggle source
# File lib/chess_openings/search_tree.rb, line 154
def leaf?
  @nodes.empty?
end
size() click to toggle source
# File lib/chess_openings/search_tree.rb, line 158
def size
  @nodes.size
end