1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
[](https://godoc.org/github.com/derekparker/trie)
# Trie
Data structure and relevant algorithms for extremely fast prefix/fuzzy string searching.
## Usage
Create a Trie with:
```Go
t := trie.New()
```
Add Keys with:
```Go
// Add can take in meta information which can be stored with the key.
// i.e. you could store any information you would like to associate with
// this particular key.
t.Add("foobar", 1)
```
Find a key with:
```Go
node, ok := t.Find("foobar")
meta := node.Meta()
// use meta with meta.(type)
```
Remove Keys with:
```Go
t.Remove("foobar")
```
Prefix search with:
```Go
t.PrefixSearch("foo")
```
Fast test for valid prefix:
```Go
t.HasKeysWithPrefix("foo")
```
Fuzzy search with:
```Go
t.FuzzySearch("fb")
```
## Contributing
Fork this repo and run tests with:
go test
Create a feature branch, write your tests and code and submit a pull request.
## License
MIT
|