Class: RBTree::Node Private
- Inherits:
-
Object
- Object
- RBTree::Node
- Defined in:
- lib/rbtree.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Internal node structure for RBTree.
Each node stores a key-value pair, color (red or black), and references to parent, left child, and right child nodes.
Constant Summary collapse
- RED =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Red color constant (true)
true- BLACK =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Black color constant (false)
false
Instance Attribute Summary collapse
-
#color ⇒ Symbol
private
The color of the node (:red or :black).
-
#key ⇒ Object
private
The key stored in this node.
-
#left ⇒ Node
private
The left child node.
-
#parent ⇒ Node
private
The parent node.
-
#right ⇒ Node
private
The right child node.
-
#value ⇒ Object
private
The value stored in this node.
Instance Method Summary collapse
-
#initialize(key = nil, value = nil, color = BLACK, left = nil, right = nil, parent = nil) ⇒ Node
constructor
private
Creates a new Node.
-
#pair ⇒ Array(Object, Object)
private
Returns the key-value pair.
Constructor Details
#initialize(key = nil, value = nil, color = BLACK, left = nil, right = nil, parent = nil) ⇒ Node
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a new Node.
2303 2304 2305 2306 2307 2308 2309 2310 |
# File 'lib/rbtree.rb', line 2303 def initialize(key = nil, value = nil, color = BLACK, left = nil, right = nil, parent = nil) @key = key @value = value @color = color @left = left @right = right @parent = parent end |
Instance Attribute Details
#color ⇒ Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the color of the node (:red or :black).
2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 |
# File 'lib/rbtree.rb', line 2287 class RBTree::Node attr_accessor :key, :value, :color, :left, :right, :parent # Red color constant (true) RED = true # Black color constant (false) BLACK = false # Creates a new Node. # # @param key [Object] the key # @param value [Object] the value # @param color [Boolean] the color (true=red, false=black) # @param left [Node] the left child # @param right [Node] the right child # @param parent [Node] the parent node def initialize(key = nil, value = nil, color = BLACK, left = nil, right = nil, parent = nil) @key = key @value = value @color = color @left = left @right = right @parent = parent end # Returns the key-value pair. # @return [Array(Object, Object)] the key-value pair def pair = [key, value] end |
#key ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the key stored in this node.
2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 |
# File 'lib/rbtree.rb', line 2287 class RBTree::Node attr_accessor :key, :value, :color, :left, :right, :parent # Red color constant (true) RED = true # Black color constant (false) BLACK = false # Creates a new Node. # # @param key [Object] the key # @param value [Object] the value # @param color [Boolean] the color (true=red, false=black) # @param left [Node] the left child # @param right [Node] the right child # @param parent [Node] the parent node def initialize(key = nil, value = nil, color = BLACK, left = nil, right = nil, parent = nil) @key = key @value = value @color = color @left = left @right = right @parent = parent end # Returns the key-value pair. # @return [Array(Object, Object)] the key-value pair def pair = [key, value] end |
#left ⇒ Node
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the left child node.
2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 |
# File 'lib/rbtree.rb', line 2287 class RBTree::Node attr_accessor :key, :value, :color, :left, :right, :parent # Red color constant (true) RED = true # Black color constant (false) BLACK = false # Creates a new Node. # # @param key [Object] the key # @param value [Object] the value # @param color [Boolean] the color (true=red, false=black) # @param left [Node] the left child # @param right [Node] the right child # @param parent [Node] the parent node def initialize(key = nil, value = nil, color = BLACK, left = nil, right = nil, parent = nil) @key = key @value = value @color = color @left = left @right = right @parent = parent end # Returns the key-value pair. # @return [Array(Object, Object)] the key-value pair def pair = [key, value] end |
#parent ⇒ Node
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the parent node.
2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 |
# File 'lib/rbtree.rb', line 2287 class RBTree::Node attr_accessor :key, :value, :color, :left, :right, :parent # Red color constant (true) RED = true # Black color constant (false) BLACK = false # Creates a new Node. # # @param key [Object] the key # @param value [Object] the value # @param color [Boolean] the color (true=red, false=black) # @param left [Node] the left child # @param right [Node] the right child # @param parent [Node] the parent node def initialize(key = nil, value = nil, color = BLACK, left = nil, right = nil, parent = nil) @key = key @value = value @color = color @left = left @right = right @parent = parent end # Returns the key-value pair. # @return [Array(Object, Object)] the key-value pair def pair = [key, value] end |
#right ⇒ Node
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the right child node.
2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 |
# File 'lib/rbtree.rb', line 2287 class RBTree::Node attr_accessor :key, :value, :color, :left, :right, :parent # Red color constant (true) RED = true # Black color constant (false) BLACK = false # Creates a new Node. # # @param key [Object] the key # @param value [Object] the value # @param color [Boolean] the color (true=red, false=black) # @param left [Node] the left child # @param right [Node] the right child # @param parent [Node] the parent node def initialize(key = nil, value = nil, color = BLACK, left = nil, right = nil, parent = nil) @key = key @value = value @color = color @left = left @right = right @parent = parent end # Returns the key-value pair. # @return [Array(Object, Object)] the key-value pair def pair = [key, value] end |
#value ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the value stored in this node.
2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 |
# File 'lib/rbtree.rb', line 2287 class RBTree::Node attr_accessor :key, :value, :color, :left, :right, :parent # Red color constant (true) RED = true # Black color constant (false) BLACK = false # Creates a new Node. # # @param key [Object] the key # @param value [Object] the value # @param color [Boolean] the color (true=red, false=black) # @param left [Node] the left child # @param right [Node] the right child # @param parent [Node] the parent node def initialize(key = nil, value = nil, color = BLACK, left = nil, right = nil, parent = nil) @key = key @value = value @color = color @left = left @right = right @parent = parent end # Returns the key-value pair. # @return [Array(Object, Object)] the key-value pair def pair = [key, value] end |
Instance Method Details
#pair ⇒ Array(Object, Object)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the key-value pair.
2314 |
# File 'lib/rbtree.rb', line 2314 def pair = [key, value] |