Class: RubyIndexer::PrefixTree::Node
- Inherits:
-
Object
- Object
- RubyIndexer::PrefixTree::Node
- Extended by:
- T::Generic, T::Sig
- Defined in:
- lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb
Constant Summary collapse
- Value =
type_member
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#leaf ⇒ Object
Returns the value of attribute leaf.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #collect ⇒ Object
-
#initialize(key, value, parent = nil) ⇒ Node
constructor
A new instance of Node.
Constructor Details
#initialize(key, value, parent = nil) ⇒ Node
Returns a new instance of Node.
132 133 134 135 136 137 138 |
# File 'lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb', line 132 def initialize(key, value, parent = nil) @key = key @value = value @parent = parent @children = T.let({}, T::Hash[String, Node[Value]]) @leaf = T.let(false, T::Boolean) end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
117 118 119 |
# File 'lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb', line 117 def children @children end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
120 121 122 |
# File 'lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb', line 120 def key @key end |
#leaf ⇒ Object
Returns the value of attribute leaf.
126 127 128 |
# File 'lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb', line 126 def leaf @leaf end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
129 130 131 |
# File 'lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb', line 129 def parent @parent end |
#value ⇒ Object
Returns the value of attribute value.
123 124 125 |
# File 'lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb', line 123 def value @value end |
Instance Method Details
#collect ⇒ Object
141 142 143 144 145 146 147 148 149 150 |
# File 'lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb', line 141 def collect result = T.let([], T::Array[Value]) result << value if leaf children.each_value do |node| result.concat(node.collect) end result end |