Documentation ¶
Overview ¶
Copyright 2020 Joshua J Baker. All rights reserved. Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
Index ¶
- type BTree
- func (tr *BTree) Ascend(pivot interface{}, iter func(item interface{}) bool)
- func (tr *BTree) Copy() *BTree
- func (tr *BTree) Delete(key interface{}) interface{}
- func (tr *BTree) DeleteAt(index int) interface{}
- func (tr *BTree) DeleteHint(key interface{}, hint *PathHint) interface{}
- func (tr *BTree) Descend(pivot interface{}, iter func(item interface{}) bool)
- func (tr *BTree) Get(key interface{}) interface{}
- func (tr *BTree) GetAt(index int) interface{}
- func (tr *BTree) GetHint(key interface{}, hint *PathHint) interface{}
- func (tr *BTree) Height() int
- func (tr *BTree) Len() int
- func (tr *BTree) Less(a, b interface{}) bool
- func (tr *BTree) Load(item interface{}) interface{}
- func (tr *BTree) Max() interface{}
- func (tr *BTree) Min() interface{}
- func (tr *BTree) PopMax() interface{}
- func (tr *BTree) PopMin() interface{}
- func (tr *BTree) Set(item interface{}) interface{}
- func (tr *BTree) SetHint(item interface{}, hint *PathHint) (prev interface{})
- func (tr *BTree) Walk(iter func(items []interface{}))
- type PathHint
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BTree ¶
type BTree struct {
// contains filtered or unexported fields
}
func NewNonConcurrent ¶ added in v0.6.0
NewNonConcurrent returns a new BTree which is not safe for concurrent write operations by multiple goroutines.
This is useful for when you do not need the BTree to manage the locking, but would rather do it yourself.
func (*BTree) Ascend ¶
Ascend the tree within the range [pivot, last] Pass nil for pivot to scan all item in ascending order Return false to stop iterating
func (*BTree) Copy ¶ added in v0.4.0
Copy the tree. This is a copy-on-write operation and is very fast because it only performs a shadowed copy.
func (*BTree) Delete ¶
func (tr *BTree) Delete(key interface{}) interface{}
Delete a value for a key
func (*BTree) DeleteAt ¶ added in v0.5.0
DeleteAt deletes the item at index. Return nil if the tree is empty or the index is out of bounds.
func (*BTree) DeleteHint ¶ added in v0.2.0
DeleteHint deletes a value for a key using a path hint
func (*BTree) Descend ¶
Descend the tree within the range [pivot, first] Pass nil for pivot to scan all item in descending order Return false to stop iterating
func (*BTree) GetAt ¶ added in v0.5.0
GetAt returns the value at index. Return nil if the tree is empty or the index is out of bounds.
func (*BTree) Height ¶ added in v0.2.0
Height returns the height of the tree. Returns zero if tree has no items.
func (*BTree) Less ¶ added in v0.2.1
Less is a convenience function that performs a comparison of two items using the same "less" function provided to New.
func (*BTree) Load ¶ added in v0.2.0
func (tr *BTree) Load(item interface{}) interface{}
Load is for bulk loading pre-sorted items
func (*BTree) Max ¶
func (tr *BTree) Max() interface{}
Max returns the maximum item in tree. Returns nil if the tree has no items.
func (*BTree) Min ¶
func (tr *BTree) Min() interface{}
Min returns the minimum item in tree. Returns nil if the tree has no items.
func (*BTree) PopMax ¶ added in v0.2.0
func (tr *BTree) PopMax() interface{}
PopMax removes the minimum item in tree and returns it. Returns nil if the tree has no items.
func (*BTree) PopMin ¶ added in v0.2.0
func (tr *BTree) PopMin() interface{}
PopMin removes the minimum item in tree and returns it. Returns nil if the tree has no items.
func (*BTree) Set ¶ added in v0.2.0
func (tr *BTree) Set(item interface{}) interface{}
Set or replace a value for a key