Class: Stamina::Induction::UnionFind::Node
- Inherits:
-
Object
- Object
- Stamina::Induction::UnionFind::Node
- Defined in:
- lib/stamina-induction/stamina/induction/union_find.rb
Overview
An element of the union find, keeping the index of its leader element as well as mergeable user data. This class is not intended to be used by external users of the UnionFind data structure.
Instance Attribute Summary collapse
-
#data ⇒ Object
Attached user data.
-
#parent ⇒ Object
Index of the parent element (on the way to the leader).
Instance Method Summary collapse
-
#dup ⇒ Object
Duplicates this node, ensuring that future changes will not affect the copy.
-
#initialize(parent, data) ⇒ Node
constructor
Creates a default Node instance with a specific parent index and attached user data.
Constructor Details
#initialize(parent, data) ⇒ Node
Creates a default Node instance with a specific parent index and attached user data.
123 124 125 126 |
# File 'lib/stamina-induction/stamina/induction/union_find.rb', line 123 def initialize(parent, data) @parent = parent @data = data end |
Instance Attribute Details
#data ⇒ Object
Attached user data
117 118 119 |
# File 'lib/stamina-induction/stamina/induction/union_find.rb', line 117 def data @data end |
#parent ⇒ Object
Index of the parent element (on the way to the leader)
114 115 116 |
# File 'lib/stamina-induction/stamina/induction/union_find.rb', line 114 def parent @parent end |
Instance Method Details
#dup ⇒ Object
Duplicates this node, ensuring that future changes will not affect the copy. Please note that the user data itself is not duplicated and is not expected to change. This property (not changing user data) is respected by the RPNI and BlueFringe classes as implemented in this library.
134 135 136 |
# File 'lib/stamina-induction/stamina/induction/union_find.rb', line 134 def dup Node.new(@parent, @data) end |