https://github.com/derekparker/trie
Data structure and relevant algorithms for extremely fast prefix/fuzzy string searching.
https://github.com/derekparker/trie
Last synced: 10 months ago
JSON representation
Data structure and relevant algorithms for extremely fast prefix/fuzzy string searching.
- Host: GitHub
- URL: https://github.com/derekparker/trie
- Owner: derekparker
- License: mit
- Created: 2014-03-06T22:01:49.000Z (almost 12 years ago)
- Default Branch: v3
- Last Pushed: 2024-09-16T17:44:16.000Z (over 1 year ago)
- Last Synced: 2025-04-11T06:05:39.759Z (11 months ago)
- Language: Go
- Homepage:
- Size: 74.2 KB
- Stars: 768
- Watchers: 22
- Forks: 117
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go-cn - trie
- awesome-go-info - trie
- awesome-go-plus - trie - Trie implementation in Go.  (Data Structures and Algorithms / Text Analysis)
- awesome-go - trie - Trie implementation in Go. (Data Structures and Algorithms / Text Analysis)
- awesome-go - derekparker/trie
- go-awesome-with-star-updatetime - trie - Trie implementation in Go. (Data Structures / Advanced Console UIs)
- awesome-go - trie - Data structure and relevant algorithms for extremely fast prefix/fuzzy string searching. - ★ 325 (Data Structures)
- fucking-awesome-go - trie - Trie implementation in Go. (Data Structures and Algorithms / Text Analysis)
- awesome-go - trie - Trie implementation in Go. (Data Structures / Advanced Console UIs)
- awesome-go-cn - trie
- awesome-go - trie - | - | - | (Data Structures / Advanced Console UIs)
- awesome-go - trie - Trie implementation in Go. (Data Structures / Advanced Console UIs)
- fucking-awesome-go - :octocat: trie - Trie implementation in Go :star: 123 :fork_and_knife: 15 (Data Structures / Advanced Console UIs)
- awesome-go - trie - Trie implementation in Go. (Data Structures and Algorithms / Text Analysis)
- awesome-go-with-stars - trie - 10-15 | (Data Integration Frameworks / Text Analysis)
- awesome-go - trie - Trie implementation in Go. (Data Structures and Algorithms / Text Analysis)
- awesome-go - trie - Trie implementation in Go. (Data Structures and Algorithms / Text Analysis)
- awesome-go-extra - trie - 03-06T22:01:49Z|2022-03-19T00:15:59Z| (Generators / Text Analysis)
- awesome-go-processed - trie - Trie implementation in Go.| (Data Structures / Advanced Console UIs)
- awesome-go-cn - trie
- awesome-go - trie - Trie implementation in Go. (Data Structures and Algorithms / Text Analysis)
- awesome-go-cn - trie
- awesome-Char - trie - Trie implementation in Go. (Data Structures / Advanced Console UIs)
- awesome-go - trie - Trie implementation in Go. - :arrow_down:4 - :star:142 (Data Structures / Advanced Console UIs)
- awesome-go - trie - GO语言实现Trie。 (<span id="数据结构-data-structures">数据结构 Data Structures</span> / <span id="高级控制台用户界面-advanced-console-uis">高级控制台用户界面 Advanced Console UIs</span>)
- awesome-go - trie - Trie implementation in Go. (Data Structures and Algorithms / Text Analysis)
README
[](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