Class: DSA::Trie::Node
- Inherits:
-
Struct
- Object
- Struct
- DSA::Trie::Node
- Defined in:
- lib/dsa-ruby/trie.rb
Overview
Internal node structure for the trie.
Instance Attribute Summary collapse
-
#children ⇒ Hash
Map of character to child node.
-
#word_end ⇒ Boolean
True if this node marks the end of a word.
Instance Method Summary collapse
-
#initialize ⇒ Node
constructor
A new instance of Node.
Constructor Details
#initialize ⇒ Node
Returns a new instance of Node.
20 21 22 |
# File 'lib/dsa-ruby/trie.rb', line 20 def initialize super(children: {}, word_end: false) end |
Instance Attribute Details
#children ⇒ Hash
Returns map of character to child node.
19 20 21 22 23 |
# File 'lib/dsa-ruby/trie.rb', line 19 Node = Struct.new(:children, :word_end, keyword_init: true) do def initialize super(children: {}, word_end: false) end end |
#word_end ⇒ Boolean
Returns true if this node marks the end of a word.
19 20 21 22 23 |
# File 'lib/dsa-ruby/trie.rb', line 19 Node = Struct.new(:children, :word_end, keyword_init: true) do def initialize super(children: {}, word_end: false) end end |