Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tidwall/tinybtree
Just an itsy bitsy b-tree in Go
https://github.com/tidwall/tinybtree
Last synced: 2 months ago
JSON representation
Just an itsy bitsy b-tree in Go
- Host: GitHub
- URL: https://github.com/tidwall/tinybtree
- Owner: tidwall
- License: mit
- Created: 2018-10-24T23:08:09.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-08-29T15:46:51.000Z (over 3 years ago)
- Last Synced: 2024-08-03T17:19:21.733Z (5 months ago)
- Language: Go
- Size: 10.7 KB
- Stars: 94
- Watchers: 5
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- go-awesome - tinybtree - B-tree (Open source library / Data Structure)
README
# `tinybtree`
[![GoDoc](https://godoc.org/github.com/tidwall/tinybtree?status.svg)](https://godoc.org/github.com/tidwall/tinybtree)
Just an itsy bitsy b-tree.
## Usage
Keys are strings, values are interfaces.
### Functions
```
Get(key string) (value interface{}, gotten bool)
Set(key string, value interface{}) (prev interface{}, replaced bool)
Delete(key string) (prev interface{}, deleted bool)
Scan(iter func(key string, value interface{}) bool)
Ascend(pivot string, iter func(key string, value interface{}) bool)
Descend(pivot string, iter func(key string, value interface{}) bool)
```### Example
```go
// Create a btree
var tr tinybtree.BTree// Set a key. Returns the previous value and ok a previous value exists.
prev, ok := tr.Set("hello", "world")// Get a key. Returns the value and ok if the value exists.
value, ok := tr.Get("hello")// Delete a key. Returns the deleted value and ok if the previous value exists.
prev, ok := tr.Delete("hello")
```## Contact
Josh Baker [@tidwall](http://twitter.com/tidwall)
## License
`tinybtree` source code is available under the MIT [License](/LICENSE).