Class: DSA::Trie::Node

Inherits:
Struct
  • Object
show all
Defined in:
lib/dsa-ruby/trie.rb

Overview

Internal node structure for the trie.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNode

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

#childrenHash

Returns map of character to child node.

Returns:

  • (Hash)

    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_endBoolean

Returns true if this node marks the end of a word.

Returns:

  • (Boolean)

    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