Class: DS::RedBlackTree::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/ds/trees/red_black_tree/node.rb

Overview

Red Black Tree Node

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value, color) ⇒ Node

Returns a new instance of Node.



8
9
10
11
12
13
14
# File 'lib/ds/trees/red_black_tree/node.rb', line 8

def initialize(key, value, color)
  @key = key
  @data = value
  @color = color
  @left = nil
  @right = nil
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



6
7
8
# File 'lib/ds/trees/red_black_tree/node.rb', line 6

def color
  @color
end

#dataObject

Returns the value of attribute data.



6
7
8
# File 'lib/ds/trees/red_black_tree/node.rb', line 6

def data
  @data
end

#keyObject

Returns the value of attribute key.



6
7
8
# File 'lib/ds/trees/red_black_tree/node.rb', line 6

def key
  @key
end

#leftObject

Returns the value of attribute left.



6
7
8
# File 'lib/ds/trees/red_black_tree/node.rb', line 6

def left
  @left
end

#rightObject

Returns the value of attribute right.



6
7
8
# File 'lib/ds/trees/red_black_tree/node.rb', line 6

def right
  @right
end

Instance Method Details

#childrenObject



16
17
18
# File 'lib/ds/trees/red_black_tree/node.rb', line 16

def children
  [@left, @right]
end