tile38/vendor/github.com/tidwall/tinybtree
tidwall 92c1ce8ef9 Update tinybtree dep 2019-02-11 13:39:29 -07:00
..
LICENSE Update tinybtree dep 2019-02-11 13:39:29 -07:00
README.md Update tinybtree dep 2019-02-11 13:39:29 -07:00
btree.go Update tinybtree dep 2019-02-11 13:39:29 -07:00
btree_test.go Update tinybtree dep 2019-02-11 13:39:29 -07:00

README.md

tinybtree

GoDoc

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

// 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

License

tinybtree source code is available under the MIT License.