Documentation
¶
Index ¶
- type Iterator
- type Node
- func (n *Node) Get(k []byte) (interface{}, bool)
- func (n *Node) Iterator() *Iterator
- func (n *Node) Maximum() ([]byte, interface{}, bool)
- func (n *Node) Minimum() ([]byte, interface{}, bool)
- func (n *Node) ReverseIterator() *ReverseIterator
- func (n *Node) Walk(fn WalkFn)
- func (n *Node) WalkBackwards(fn WalkFn)
- func (n *Node) WalkPath(path []byte, fn WalkFn)
- func (n *Node) WalkPrefix(prefix []byte, fn WalkFn)
- type ReverseIterator
- type Tree
- type Txn
- type WalkFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator is used to iterate over a set of nodes in pre-order
func (*Iterator) SeekLowerBound ¶
SeekLowerBound is used to seek the iterator to the smallest key that is greater or equal to the given key. There is no watch variant as it's hard to predict based on the radix structure which node(s) changes might affect the result.
func (*Iterator) SeekPrefix ¶
SeekPrefix is used to seek the iterator to a given prefix
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is an immutable node in the radix tree
func (*Node) ReverseIterator ¶
func (n *Node) ReverseIterator() *ReverseIterator
ReverseIterator is used to return an iterator at the given node to walk the tree backwards
func (*Node) WalkBackwards ¶
WalkBackwards is used to walk the tree in reverse order
func (*Node) WalkPath ¶
WalkPath is used to walk the tree, but only visiting nodes from the root down to a given leaf. Where WalkPrefix walks all the entries *under* the given prefix, this walks the entries *above* the given prefix.
func (*Node) WalkPrefix ¶
WalkPrefix is used to walk the tree under a prefix
type ReverseIterator ¶
type ReverseIterator struct {
// contains filtered or unexported fields
}
ReverseIterator is used to iterate over a set of nodes in reverse in-order
func NewReverseIterator ¶
func NewReverseIterator(n *Node) *ReverseIterator
NewReverseIterator returns a new ReverseIterator at a node
func (*ReverseIterator) Previous ¶
func (ri *ReverseIterator) Previous() ([]byte, interface{}, bool)
Previous returns the previous node in reverse order
func (*ReverseIterator) SeekPrefix ¶
func (ri *ReverseIterator) SeekPrefix(prefix []byte)
SeekPrefix is used to seek the iterator to a given prefix
func (*ReverseIterator) SeekReverseLowerBound ¶
func (ri *ReverseIterator) SeekReverseLowerBound(key []byte)
SeekReverseLowerBound is used to seek the iterator to the largest key that is lower or equal to the given key. There is no watch variant as it's hard to predict based on the radix structure which node(s) changes might affect the result.
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree implements an immutable radix tree. This can be treated as a Dictionary abstract data type. The main advantage over a standard hash map is prefix-based lookups and ordered iteration. The immutability means that it is safe to concurrently read from a Tree without any coordination.
func (*Tree) Delete ¶
Delete is used to delete a given key. Returns the new tree, old value if any, and a bool indicating if the key was set.
func (*Tree) DeletePrefix ¶
DeletePrefix is used to delete all nodes starting with a given prefix. Returns the new tree, and a bool indicating if the prefix matched any nodes
func (*Tree) Insert ¶
Insert is used to add or update a given key. The return provides the new tree, previous value and a bool indicating if any was set.
type Txn ¶
type Txn struct {
// contains filtered or unexported fields
}
Txn is a transaction on the tree. This transaction is applied atomically and returns a new tree when committed. A transaction is not thread safe, and should only be used by a single goroutine.
func (*Txn) Commit ¶
Commit is used to finalize the transaction and return a new tree. Indicates if the Tree has been mutated
func (*Txn) Delete ¶
Delete is used to delete a given key. Returns the old value if any, and a bool indicating if the key was set.
func (*Txn) DeletePrefix ¶
DeletePrefix is used to delete an entire subtree that matches the prefix This will delete all nodes under that prefix