go-trie
A primitive implementation of the Trie data structure in Golang. The Trie data
structure allows for quick information retrieval, typically strings, and prefix
searching. It stores data as an associative array. Keys and their respective
values are stored as bytes.
Typically, values in a Trie are unnecessary, rather, they are not traditionally
needed. In such cases such as these, you can simply store some terminal or
constant value.
Usage
trie := NewTrie()
trie.Insert([]byte("someKey"), []byte("someValue"))
value, ok := trie.Search([]byte("someKey"))
keys := trie.GetAllKeys()
values := trie.GetAllValues()
keyByPrefix := trie.GetPrefixKeys([]byte("somePrefix"))
valuesByPrefix := trie.GetPrefixValues(prefix)
Tests
$ go test -v
Contributing
- Fork it
- Create your feature branch (
git checkout -b feature/my-new-feature
) - Commit your changes (
git commit -m 'Add some feature'
) - Push to the branch (
git push origin feature/my-new-feature
) - Create a new Pull Request