{"id":15486957,"url":"https://github.com/theodesp/go-tries","last_synced_at":"2025-03-28T16:14:40.375Z","repository":{"id":97066527,"uuid":"112502102","full_name":"theodesp/go-tries","owner":"theodesp","description":"Go tries implements several types of Trie data structures for experimental use.","archived":false,"fork":false,"pushed_at":"2017-12-06T11:18:25.000Z","size":27,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-02T16:19:46.842Z","etag":null,"topics":["data-structures","golang","trie"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theodesp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2017-11-29T16:50:43.000Z","updated_at":"2018-02-03T11:54:07.000Z","dependencies_parsed_at":"2023-03-13T16:19:36.149Z","dependency_job_id":null,"html_url":"https://github.com/theodesp/go-tries","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2Fgo-tries","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2Fgo-tries/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2Fgo-tries/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2Fgo-tries/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theodesp","download_url":"https://codeload.github.com/theodesp/go-tries/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246059336,"owners_count":20717085,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["data-structures","golang","trie"],"created_at":"2024-10-02T06:20:32.570Z","updated_at":"2025-03-28T16:14:40.349Z","avatar_url":"https://github.com/theodesp.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Tries\n\n\nGo tries implements several types of Tries for experimental use.\n\nThe implementations are optimized for Get performance and to allocate \n0 bytes of heap memory (i.e. garbage) per Get.\n\nA typical use case is to perform Puts and Deletes upfront to populate the Trie, \nthen perform Gets very quickly.\n\nWhen Tries are chosen over maps, it is typically for their space efficiency.\n\n\nTrie Types\n---\n\n**SimpleTrie**: A simple implementation using a map of TrieNodes.\n\n```go\nt := NewSimpleTrie()\nt.Add(\"cat\", 0)\nt.Add(\"fox\", 1)\nt.Add(\"dog\", 2)\nt.Add(\"dog and\", 3)\nt.Add(\"dog and cat\", 4)\n\nt.Get(\"Cat\") // nil\nt.Get(\"cat\") // cat\n```\n\n* It has a bigger memory footprint.\n* It is fast for finding not existing keys.\n* It gets slower as the keys become complicated with lots of spaces between as the algorithm will split the words first.\n* Put operations are heavier.\n\n**DoubleArrayTrie**: A more complex implementation of a Trie using 2 Lists. \nThis is supposed to have better search performance in expense of slower insertions.\nBased on the [Sato and Morimoto paper](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.14.8665\u0026rep=rep1\u0026type=pdf)\n\n* It has a smaller memory footprint. Only 3 slices that resize when necessary.\n* It is fast for finding keys\n* It does not get substantially slower when the keys become complicated with lots of spaces between, \nas the algorithm has a good amortized cost over the `Get` operations. \nThe heaviest operation is `ReadTail` which just tries to concat slices.\n\nBenchmarks\n---\n**Single threaded benchmarks**: Simple Trie.\n```bash\nBenchmarkSimpleTriePutStringKey-4       50000000                35.6 ns/op             8 B/op          1 allocs/op\nBenchmarkSimpleTrieGetStringKey-4       100000000               16.0 ns/op             0 B/op          0 allocs/op\nBenchmarkSimpleTriePutPhraseKey-4       20000000                69.5 ns/op             8 B/op          1 allocs/op\nBenchmarkSimpleTrieGetPhraseKey-4       30000000                42.1 ns/op             0 B/op          0 allocs/op\n```\n\nSingle threaded benchmarks: Double Array Trie\n```bash\nBenchmarkDoubleArrayTrieGetSimpleStringKey-4    50000000                26.7 ns/op             0 B/op          0 allocs/op\n```\n\nLicense\n---\n\nMIT License","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheodesp%2Fgo-tries","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheodesp%2Fgo-tries","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheodesp%2Fgo-tries/lists"}