This is a dictionary implemented as a trie, inspired by Tyler McMullen's LA RubyConf 2010 talk: http://www.scribd.com/doc/27149829/Alternative-Data-Structures-in-Ruby
There are also naive implementations using Array and Set that are fun for comparing performance and memory footprint.
How to use it:
>> require 'trie_dictionary' => true >> d = Dictionary.new => # >> d.add ("fish") (irb):7: warning: don't put space before argument parentheses => true >> d.add("fiend") => true >> d.add("foo") => true >> d.find('f') => ["fish", "fiend", "foo"] >> d.find('fi') => ["fish", "fiend"] >> d.find('fo') => ["foo"]
Alternate implementation Performance results: