{"id":13694281,"url":"https://github.com/dghubble/trie","last_synced_at":"2025-04-07T01:12:48.619Z","repository":{"id":23978786,"uuid":"27361698","full_name":"dghubble/trie","owner":"dghubble","description":"Fast, zero heap allocation Go Trie for runes or paths","archived":false,"fork":false,"pushed_at":"2024-09-20T20:22:28.000Z","size":36,"stargazers_count":488,"open_issues_count":1,"forks_count":56,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-03-31T00:13:36.579Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":false,"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/dghubble.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","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},"funding":{"github":["dghubble"]}},"created_at":"2014-12-01T03:57:25.000Z","updated_at":"2025-03-25T09:12:23.000Z","dependencies_parsed_at":"2024-10-22T22:55:45.255Z","dependency_job_id":null,"html_url":"https://github.com/dghubble/trie","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dghubble%2Ftrie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dghubble%2Ftrie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dghubble%2Ftrie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dghubble%2Ftrie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dghubble","download_url":"https://codeload.github.com/dghubble/trie/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247574095,"owners_count":20960496,"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":[],"created_at":"2024-08-02T17:01:28.509Z","updated_at":"2025-04-07T01:12:48.604Z","avatar_url":"https://github.com/dghubble.png","language":"Go","funding_links":["https://github.com/sponsors/dghubble"],"categories":["开源类库","Open source library"],"sub_categories":["数据结构","Data Structure"],"readme":"# Trie\n[![GoDoc](https://pkg.go.dev/badge/github.com/dghubble/trie.svg)](https://pkg.go.dev/github.com/dghubble/trie)\n[![Workflow](https://github.com/dghubble/trie/actions/workflows/test.yaml/badge.svg)](https://github.com/dghubble/trie/actions/workflows/test.yaml?query=branch%3Amain)\n[![Sponsors](https://img.shields.io/github/sponsors/dghubble?logo=github)](https://github.com/sponsors/dghubble)\n[![Mastodon](https://img.shields.io/badge/follow-news-6364ff?logo=mastodon)](https://fosstodon.org/@dghubble)\n\nPackage `trie` implements rune-wise and path-wise [Tries](https://en.wikipedia.org/wiki/Trie) optimized for `Get` performance and to allocate 0 bytes of heap memory (i.e. garbage) per `Get`.\n\nA typical use case is to perform any `Put` or `Delete` operations upfront to populate the trie, then perform `Get` operations very quickly. The Tries do not synchronize access (not thread-safe).\n\nWhen Tries are chosen over maps, it is typically for their space efficiency. However, in situations where direct key lookup is not possible (e.g. routers), tries can provide faster lookups and avoid key iteration.\n\n## Install\n\n```\n$ go get github.com/dghubble/trie\n```\n\n## Documentation\n\nRead [Godoc](https://godoc.org/github.com/dghubble/trie)\n\n## Performance\n\nRuneTrie is a typical Trie which segments strings rune-wise (i.e. by unicode code point). These benchmarks perform Puts and Gets of random string keys that are 30 bytes long and of random '/' separated paths that have 3 parts and are 30 bytes long (longer if you count the '/' seps).\n\n```\nBenchmarkRuneTriePutStringKey-8   3000000    437 ns/op     9 B/op     1 allocs/op\nBenchmarkRuneTrieGetStringKey-8   3000000    411 ns/op     0 B/op     0 allocs/op\nBenchmarkRuneTriePutPathKey-8     3000000    464 ns/op     9 B/op     1 allocs/op\nBenchmarkRuneTrieGetPathKey-8     3000000    429 ns/op     0 B/op     0 allocs/op\n```\n\nPathTrie segments strings by forward slash separators which can boost performance\nfor some use cases. These benchmarks perform Puts and Gets of random string keys that are 30 bytes long and of random '/' separated paths that have 3 parts and are 30 bytes long (longer if you count the '/' seps).\n\n```\nBenchmarkPathTriePutStringKey-8   30000000   55.5 ns/op    8 B/op     1 allocs/op\nBenchmarkPathTrieGetStringKey-8   50000000   37.9 ns/op    0 B/op     0 allocs/op\nBenchmarkPathTriePutPathKey-8     20000000   88.7 ns/op    8 B/op     1 allocs/op\nBenchmarkPathTrieGetPathKey-8     20000000   68.6 ns/op    0 B/op     0 allocs/op\n```\n\nNote that for random string Puts and Gets, the PathTrie is effectively a map as every node is a direct child of the root (except for strings that happen to have a slash).\n\nThis benchmark measures the performance of the PathSegmenter alone. It is used to segment random paths that have 3 '/' separated parts and are 30 bytes long.\n\n```\nBenchmarkPathSegmenter-8          50000000   32.0 ns/op    0 B/op     0 allocs/op\n```\n\n## License\n\n[MIT License](LICENSE)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdghubble%2Ftrie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdghubble%2Ftrie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdghubble%2Ftrie/lists"}