{"id":13711012,"url":"https://github.com/hslam/btree","last_synced_at":"2025-06-29T12:37:33.353Z","repository":{"id":57555026,"uuid":"309559896","full_name":"hslam/btree","owner":"hslam","description":"Package btree implements a B-tree.","archived":false,"fork":false,"pushed_at":"2022-04-28T13:57:06.000Z","size":140,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T11:32:40.349Z","etag":null,"topics":["b-tree","btree","go","golang","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/hslam.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-11-03T03:20:23.000Z","updated_at":"2023-06-14T06:25:59.000Z","dependencies_parsed_at":"2022-09-26T18:51:34.840Z","dependency_job_id":null,"html_url":"https://github.com/hslam/btree","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/hslam/btree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Fbtree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Fbtree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Fbtree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Fbtree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hslam","download_url":"https://codeload.github.com/hslam/btree/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Fbtree/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262596532,"owners_count":23334625,"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":["b-tree","btree","go","golang","tree"],"created_at":"2024-08-02T23:01:03.395Z","updated_at":"2025-06-29T12:37:33.303Z","avatar_url":"https://github.com/hslam.png","language":"Go","funding_links":[],"categories":["Repositories"],"sub_categories":[],"readme":"# btree\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/hslam/btree)](https://pkg.go.dev/github.com/hslam/btree)\n[![Build Status](https://github.com/hslam/btree/workflows/build/badge.svg)](https://github.com/hslam/btree/actions)\n[![codecov](https://codecov.io/gh/hslam/btree/branch/master/graph/badge.svg)](https://codecov.io/gh/hslam/btree)\n[![Go Report Card](https://goreportcard.com/badge/github.com/hslam/btree)](https://goreportcard.com/report/github.com/hslam/btree)\n[![LICENSE](https://img.shields.io/github/license/hslam/btree.svg?style=flat-square)](https://github.com/hslam/btree/blob/master/LICENSE)\n\nPackage btree implements a B-tree.\n\n#### Definition\nAccording to Knuth's definition, a **[B-tree](https://en.wikipedia.org/wiki/B-tree \"B-tree\")** of order m is a tree which satisfies the following properties:\n* Every node has at most m children.\n* Every non-leaf node (except root) has at least ⌈m/2⌉ child nodes.\n* The root has at least two children if it is not a leaf node.\n* A non-leaf node with k children contains k − 1 keys.\n* All leaves appear in the same level and carry no information.\n\n## [Benchmark](http://github.com/hslam/btree-benchmark \"btree-benchmark\")\n\n\u003cimg src=\"https://raw.githubusercontent.com/hslam/btree-benchmark/master/btree-insert.png\" width = \"400\" height = \"300\" alt=\"insert\" align=center\u003e\u003cimg src=\"https://raw.githubusercontent.com/hslam/btree-benchmark/master/btree-delete.png\" width = \"400\" height = \"300\" alt=\"delete\" align=center\u003e\n\n\u003cimg src=\"https://raw.githubusercontent.com/hslam/btree-benchmark/master/btree-search.png\" width = \"400\" height = \"300\" alt=\"search\" align=center\u003e\u003cimg src=\"https://raw.githubusercontent.com/hslam/btree-benchmark/master/btree-iterate.png\" width = \"400\" height = \"300\" alt=\"iterate\" align=center\u003e\n\n\n## Get started\n\n### Install\n```\ngo get github.com/hslam/btree\n```\n### Import\n```\nimport \"github.com/hslam/btree\"\n```\n### Usage\n#### Example\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/hslam/btree\"\n)\n\nfunc main() {\n\ttree := btree.New(2)\n\tstr := String(\"Hello World\")\n\ttree.Insert(str)\n\tfmt.Println(tree.Search(str))\n\ttree.Delete(str)\n}\n\ntype String string\n\nfunc (a String) Less(b btree.Item) bool {\n\treturn a \u003c b.(String)\n}\n```\n\n#### Output\n```\nHello World\n```\n\n#### Iterator Example\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/hslam/btree\"\n)\n\nfunc main() {\n\ttree := btree.New(2)\n\tfor i := 0; i \u003c 10; i++ {\n\t\ttree.Insert(Int(i))\n\t}\n\titer := tree.Min().MinIterator()\n\tfor iter != nil {\n\t\tfmt.Printf(\"%d\\t\", iter.Item())\n\t\titer = iter.Next()\n\t}\n}\n\ntype Int int\n\nfunc (a Int) Less(b btree.Item) bool {\n\treturn a \u003c b.(Int)\n}\n```\n#### B-Tree\n\u003cimg src=\"https://raw.githubusercontent.com/hslam/btree/master/btree.png\" alt=\"btree\" align=center\u003e\n\n#### Output\n```\n0\t1\t2\t3\t4\t5\t6\t7\t8\t9\n```\n\n### License\nThis package is licensed under a MIT license (Copyright (c) 2020 Meng Huang)\n\n### Author\nbtree was written by Meng Huang.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhslam%2Fbtree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhslam%2Fbtree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhslam%2Fbtree/lists"}