{"id":21648062,"url":"https://github.com/markelog/trie","last_synced_at":"2025-11-06T21:03:33.830Z","repository":{"id":57482257,"uuid":"113781304","full_name":"markelog/trie","owner":"markelog","description":"Implementation of \"Trie\" data structure","archived":false,"fork":false,"pushed_at":"2017-12-30T08:34:58.000Z","size":3616,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T01:54:56.287Z","etag":null,"topics":["algorithm","data-structure","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/markelog.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}},"created_at":"2017-12-10T20:31:58.000Z","updated_at":"2017-12-10T23:12:24.000Z","dependencies_parsed_at":"2022-09-02T06:11:49.040Z","dependency_job_id":null,"html_url":"https://github.com/markelog/trie","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/markelog/trie","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markelog%2Ftrie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markelog%2Ftrie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markelog%2Ftrie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markelog%2Ftrie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markelog","download_url":"https://codeload.github.com/markelog/trie/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markelog%2Ftrie/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267317567,"owners_count":24068476,"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","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["algorithm","data-structure","trie"],"created_at":"2024-11-25T06:53:14.536Z","updated_at":"2025-11-06T21:03:33.790Z","avatar_url":"https://github.com/markelog.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Trie [![Build Status](https://travis-ci.org/markelog/trie.svg?branch=master)](https://travis-ci.org/markelog/trie) [![GoDoc](https://godoc.org/github.com/markelog/trie?status.svg)](https://godoc.org/github.com/markelog/trie) [![Go Report Card](https://goreportcard.com/badge/github.com/markelog/trie)](https://goreportcard.com/report/github.com/markelog/trie) [![Coverage ](https://coveralls.io/repos/github/markelog/trie/badge.svg?branch=master)](https://coveralls.io/github/markelog/trie?branch=master)\n\n\u003e Implementation of \"Trie\" data structure\n\nSee https://en.wikipedia.org/wiki/Trie. Why yet another \"trie\" implementation?\n\nSome of them do not expose needed methods like traversing, some of them do not expose\nparents or children. And some of them just plain peculiar. At least I think so :)\n\n## Install\n```sh\ngo get github.com/markelog/trie\n```\n\n## Usage\n\nSimple example here, see [docs](https://godoc.org/github.com/markelog/trie) for more stuff and explanations\n\n\n```go\npackage main\n\nimport (\n\t\"github.com/markelog/trie\"\n\t\"github.com/markelog/trie/node\"\n)\n\nfunc main() {\n\ttree := trie.New()\n\n\ttree.Add(\"cool\", \"So cool\")\n\ttree.Add(\"coolio\", 54) // Age of his at the moment of writing\n\n\tprintln(tree.Size) // 2\n\n\tprintln(tree.Contains(\"cool\")) // true\n\n\tprintln(len(tree.Root.Children))   // 1\n\tprintln(tree.Root.Children[0].Key) // \"cool\"\n\n\tresults := tree.Search(\"cool\") // []string{\"cool\", \"coolio\"}\n\tcool := results[0]\n\n\tprintln(cool.Value.(string))  // \"So cool\"\n\tprintln(cool.Children[0].Key) // \"coolio\"\n\n\tcoolio := tree.Find(\"coolio\")\n\n\tprintln(coolio.Value.(int)) // 54\n\n\tprintln(coolio.Key)        // \"coolio\"\n\tprintln(coolio.Parent.Key) // \"cool\"\n\n\ti := 0\n\ttree.Traverse(func(item *node.Node) bool {\n\t\ti++\n\t\treturn true\n\t})\n\n\tprintln(i) // 2\n\n\ti = 0\n\ttree.Visit(cool, func(item *node.Node) bool {\n\t\ti++\n\t\treturn true\n\t})\n\n\tprintln(i) // 1\n\n\t// Including branches\n\ti = 0\n\ttree.VisitAll(cool, func(item *node.Node) bool {\n\t\ti++\n\t\treturn true\n\t})\n\n\tprintln(i) // 2\n}\n\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkelog%2Ftrie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkelog%2Ftrie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkelog%2Ftrie/lists"}