https://github.com/karrick/gotrie
Go library that implements a Trie data structure.
https://github.com/karrick/gotrie
data-structures golang golang-library
Last synced: 9 months ago
JSON representation
Go library that implements a Trie data structure.
- Host: GitHub
- URL: https://github.com/karrick/gotrie
- Owner: karrick
- License: mit
- Created: 2018-10-12T17:18:33.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-23T13:31:13.000Z (over 6 years ago)
- Last Synced: 2025-03-05T17:40:27.042Z (about 1 year ago)
- Topics: data-structures, golang, golang-library
- Language: Go
- Size: 7.81 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gotrie
Go library that implements a Trie data structure.
[](https://godoc.org/github.com/karrick/gotrie)
## Example
```Go
package main
import (
"bufio"
"fmt"
"os"
"github.com/karrick/gotrie"
)
func main() {
// build a new Trie from standard input lines
t := gotrie.NewPrefixTrie()
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
t.Insert(scanner.Text(), struct{}{})
}
if err := scanner.Err(); err != nil {
fmt.Fprintf(os.Stderr, "ERROR: %s\n", err)
os.Exit(1)
}
// Enumerate through Trie in sorted order
for t.Scan() {
fmt.Println(t.Text())
}
}
```