{"id":18836301,"url":"https://github.com/obitech/go-trees","last_synced_at":"2025-04-14T05:30:55.459Z","repository":{"id":54883900,"uuid":"324568313","full_name":"obitech/go-trees","owner":"obitech","description":"BST, Red-Black-Tree \u0026 Interval Tree in Golang","archived":false,"fork":false,"pushed_at":"2021-01-22T13:35:33.000Z","size":52,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-27T19:22:49.175Z","etag":null,"topics":["binary-search-tree","golang","interval-tree","redblack-tree"],"latest_commit_sha":null,"homepage":"","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/obitech.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":"2020-12-26T14:09:34.000Z","updated_at":"2024-04-04T00:15:22.000Z","dependencies_parsed_at":"2022-08-14T05:40:38.451Z","dependency_job_id":null,"html_url":"https://github.com/obitech/go-trees","commit_stats":null,"previous_names":["obitech/go-tree"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obitech%2Fgo-trees","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obitech%2Fgo-trees/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obitech%2Fgo-trees/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obitech%2Fgo-trees/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/obitech","download_url":"https://codeload.github.com/obitech/go-trees/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248826487,"owners_count":21167698,"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":["binary-search-tree","golang","interval-tree","redblack-tree"],"created_at":"2024-11-08T02:21:18.352Z","updated_at":"2025-04-14T05:30:55.197Z","avatar_url":"https://github.com/obitech.png","language":"Go","readme":"# go-tree: Tree implementations in Golang\n\n\u003ca href='https://github.com/jpoles1/gopherbadger' target='_blank'\u003e![gopherbadger-tag-do-not-edit](https://img.shields.io/badge/Go%20Coverage-82%25-brightgreen.svg?longCache=true\u0026style=flat)\u003c/a\u003e\n\n## package [bst](./bst)\n\nImplements a [Binary Search Tree](https://en.wikipedia.org/wiki/Binary_search_tree).\n\n## package [redblack](./redblack)\n\nImplements a [Red-Black-Tree](https://en.wikipedia.org/wiki/Red%E2%80%93black_tree).\n\n### Example\n\n```go\ntree := NewRedBlackTree()\n\n// Operations on arbitrary keys are allow as long as the type implements they \n// Key interface.\ntype myInt int\n\nfunc (i myInt) Less(v Key) bool {\n    return i \u003c v.(myInt)\n}\n\n// Insert items.\ntree.Upsert(myInt(5), \"test\")\ntree.Upsert(myInt(10), \"foo\")\ntree.Upsert(myInt(15), 42)\n\n// Search for an item.\nfmt.Println(tree.Search(15)) \n\n// Replace a payload.\ntree.Upsert(myInt(15), \"bar\")\n```\n\n### Benchmarks\n\n````\ngoos: darwin\ngoarch: amd64\npkg: github.com/obitech/go-tree/redblack\nBenchmarkRBTree_Upsert-8                 2012917               775 ns/op              31 B/op          0 allocs/op\nBenchmarkRBTree_Search10_000-8          11450182               102 ns/op               0 B/op          0 allocs/op\nBenchmarkRBTree_Search100_000-8          5394513               235 ns/op               0 B/op          0 allocs/op\nBenchmarkRBTree_Search1_000_000-8         411782              2487 ns/op             117 B/op          3 allocs/op\nBenchmarkRBTree_Delete10_000-8          25755091                43.7 ns/op             0 B/op          0 allocs/op\nBenchmarkRBTree_Delete100_000-8         23051653                46.5 ns/op             0 B/op          0 allocs/op\nBenchmarkRBTree_Delete1_000_000-8          37518             26899 ns/op            1291 B/op         43 allocs/op\n````\n\n## package [interval](./interval)\n\nImplements an [Interval tree](https://en.wikipedia.org/wiki/Interval_tree)\n\n### Example\n\n```go\ntree := NewIntervalTree()\n\nnov, err := NewInterval(newTime(t, \"2020-Nov-01\"), newTime(t, \"2020-Nov-02\"))\nif err != nil {\n\tpanic(err)\n}\n\n\nfeb, err := NewInterval(newTime(t, \"2020-Feb-01\"), newTime(t, \"2020-Feb-02\"))\nif err != nil {\n\tpanic(err)\n}\n\ndec, err := NewInterval(newTime(t, \"2020-Dec-01\"), newTime(t, \"2020-Dec-02\"))\nif err != nil {\n\tpanic(err)\n}\n\ntree.Upsert(nov)\ntree.Upsert(feb)\ntree.Upsert(dec)\n\nsearch1, err := NewInterval(newTime(t, \"2020-Feb-01\"), newTime(t, \"2021-Feb-02\"))\n\nr, err := tree.FindFirstOverlapping(search)\nif err != nil {\n\tfmt.Println(\"no overlapping interval found for %s\", search1)\n}\n\nr, err = tree.FindAllOverlapping(search)\nif err != nil {\n    fmt.Println(\"no overlapping interval found for %s\", search1)\n}\n```\n\n### Benchmarks\n\nTODO","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobitech%2Fgo-trees","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fobitech%2Fgo-trees","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobitech%2Fgo-trees/lists"}