Class: Rambling::Trie::Compressor

Inherits:
Object
  • Object
show all
Defined in:
lib/rambling/trie/compressor.rb

Overview

Responsible for the compression process of a trie data structure.

Instance Method Summary collapse

Instance Method Details

#compress(node) ⇒ Nodes::Compressed?

Compresses a Node from a trie data structure.

Parameters:

Returns:



10
11
12
13
14
15
16
17
18
# File 'lib/rambling/trie/compressor.rb', line 10

def compress node
  return unless node

  if node.compressible?
    compress_only_child_and_merge node
  else
    compress_children_and_copy node
  end
end