Rambling Trie A Ruby implementation of the Trie data structure

Build Status Dependency Status Code Climate Code Climate

The Rambling Trie is a custom Ruby implementation of the trie data structure. It is designed to be fast to traverse and easy to use.

Installation

You can install the rambling-trie gem like this:

gem install rambling-trie

Or add it to your Gemfile like this:

gem 'rambling-trie'

Usage

To get a new instance just type:

trie = Rambling::Trie.create
# or
trie = Rambling::Trie.create 'path/to/filename' # to create from words on a file

Then you can add words to it with:

trie.add_branch_from 'word'
# or
trie << 'word'

And you can ask if a word is contained with:

trie.is_word? 'word'
# or
trie.include? 'word'

Or if part of a word is contained with:

trie.has_branch_for? 'part_of_a_word'

You can also compress the trie:

trie.compress!

Note that you cannot add any more words to a compressed trie) and that the compress! method acts over the existing trie instance.

And you can ask if a trie is compressed:

trie.compressed?

You can find further documentation on the project's repository on GitHub or on the gem's RubyDoc.info page. You can also find edge documentation on the project's RubyDoc.info page

Support

If you find any bug, feel free to report it through the project's GitHub issues.

You can also send us an email to development@ramblinglabs.com, with your questions and feature requests.

Fork me on GitHub