Module: Rambling::Trie::Compressible

Included in:
Nodes::Node
Defined in:
lib/rambling/trie/compressible.rb

Overview

Provides the compressible behavior for the trie data structure.

Instance Method Summary collapse

Instance Method Details

#compressible?Boolean

Indicates if the current Node can be compressed or not.

Returns:

  • (Boolean)

    ‘true` for non-terminal nodes with one child, `false` otherwise.



11
12
13
# File 'lib/rambling/trie/compressible.rb', line 11

def compressible?
  !(root? || terminal?) && children_tree.size == 1
end