Class TernaryTrie
In: lib/utility/ternarytrie.rb
Parent: Object
TernaryTrie
TopLevel

class TernaryTrie implements a ternary search trie. The keys are are assumed to be strings, but the values can be any object. This is a very lightweight and useful object

Methods

find   find_exact   insert   new   to_hash  

Classes and Modules

Class TernaryTrie::TNode

Public Class methods

constructor simply ensures we have a root

Public Instance methods

Returns array of values that are the shortest possible match of the key.

key
A string
return
An array of values or nil if nothing found

Returns an exact match only of the key or nil if not found

key
A string
return
A values or nil if nothing found

Inserts a key/val pair - no duplicate keys (will replace key if found).

key
A string
value
A value which ay be any object.

Routine which converts the trie into a hash table

return
hash table of key/value pairs

[Validate]