{"id":38149454,"url":"https://github.com/gtr/trie","last_synced_at":"2026-01-16T23:00:11.271Z","repository":{"id":165666774,"uuid":"263977207","full_name":"gtr/trie","owner":"gtr","description":"quick and effective trie library implementation for go","archived":false,"fork":false,"pushed_at":"2020-05-14T17:11:41.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-19T15:08:33.130Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gtr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-14T17:10:54.000Z","updated_at":"2020-05-19T05:37:06.000Z","dependencies_parsed_at":"2024-06-19T14:52:54.614Z","dependency_job_id":"11d60470-356c-4b67-a9b8-ee8bbcc1e2f6","html_url":"https://github.com/gtr/trie","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gtr/trie","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gtr%2Ftrie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gtr%2Ftrie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gtr%2Ftrie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gtr%2Ftrie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gtr","download_url":"https://codeload.github.com/gtr/trie/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gtr%2Ftrie/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28487074,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T22:54:02.790Z","status":"ssl_error","status_checked_at":"2026-01-16T22:50:10.344Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-16T23:00:07.790Z","updated_at":"2026-01-16T23:00:11.201Z","avatar_url":"https://github.com/gtr.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"a quick and effective trie library implementation for go\n\n## install\n\nuse the `go get` command:\n\n```bash\ngo get github.com/gtr/trie\n```\n\n## usage\n\nimport the library into your go main file:\n```go\nimport \"github.com/gtr/trie\"\n```\n\nexample usage:\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/gtr/trie\"\n)\n\nfunc main() {\n\tt := trie.NewTrie()\n\tt.InsertWord(\"hello\")\n\tt.InsertWords([]string{\n\t\t\"hi\",\n\t\t\"hoop\",\n\t\t\"hook\",\n\t\t\"breakfast\",\n\t\t\"brunch\",\n\t\t\"brush\",\n\t\t\"bank\",\n\t})\n\n\tauto, err := t.AutoComplete(\"br\")\n\tif err != nil {\n\t\tlog.Fatalf(\"AutoComplete: %s\", err)\n\t}\n\n\tfor _, word := range auto {\n\t\tfmt.Println(word)\n\t}\n\n\tall := t.GetAllWords()\n\tfmt.Println(\"----\")\n\tfor _, word := range all {\n\t\tfmt.Println(word)\n\t}\n}\n\n```\n\noutput:\n```\nbreakfast\nbrush\nbrunch\n----\nhoop\nhook\nhello\nhi\nbreakfast\nbrunch\nbrush\nbank\n\n```\n\n## public api\n\n### trie\n```go\ntype Trie struct {\n    Root *Node\n}\n```\nTrie represents a trie object.\n\n```go\nfunc NewTrie() *Trie \n```\nNewTrie returns a pointer to an empty trie.\n\n```go\nfunc (t *Trie) InsertWord(word string)\n```\nInsertWord inserts a new word into the trie.\n\n```go\nfunc (t *Trie) InsertWords(words []string)\n```\nInsertWords inserts multiple words into the trie.\n\n```go\nfunc (t *Trie) FindWord(word string) bool \n```\nFindWord returns a bool if a word exists in the trie.\n\n```go\nfunc (t *Trie) GetAllWords() []string \n```\nGetAllWords returns a slice of strings containing all the words in the entire trie.\n\n```go\nfunc (t *Trie) AutoComplete(prefix string) ([]string, error)\n```\nAutoComplete returns a slice of strings containing all the possible words that can autocomplete the given prefix.\n\n### node\n\n```go\ntype Node struct {\n    IsWord      bool\n    Children    map[rune]*Node\n}\n```\nNode represents a Node in the trie.\n\n```go\nfunc NewNode() *Node\n```\nNewNode returns a pointer to an empty node.\n\n```go\nfunc (n *Node) GetAllSubWords(curr string) []string\n```\nGetAllSubWords returns a slice of strings containing all the words in the subtrie contained in the current node n.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgtr%2Ftrie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgtr%2Ftrie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgtr%2Ftrie/lists"}