Documentation ¶
Index ¶
- type Exportable
- type Tree
- func (t *Tree) Delete(s string) (interface{}, bool)
- func (t *Tree) DeletePrefix(s string) int
- func (t *Tree) Get(s string) (interface{}, bool)
- func (t *Tree) Insert(s string, v interface{}) (interface{}, bool)
- func (t *Tree) Len() int
- func (t *Tree) LongestPrefix(s string) (string, interface{}, bool)
- func (t *Tree) Maximum() (string, interface{}, bool)
- func (t *Tree) Minimum() (string, interface{}, bool)
- func (t *Tree) Save(w io.Writer) (retErr error)
- func (t *Tree) ToMap() map[string]interface{}
- func (t *Tree) Walk(fn WalkFn)
- func (t *Tree) WalkPath(path string, fn WalkFn)
- func (t *Tree) WalkPrefix(prefix string, fn WalkFn)
- type ValueFactory
- type WalkFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Exportable ¶
Exportable interface can be implemented on the client side to use preferred encoding
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree implements a 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,
func Load ¶
func Load(r io.Reader, factory ValueFactory) (*Tree, error)
Load reads the tree bytes from the reader and uses the ValueFactory to reconstruct the tree
func NewFromMap ¶
NewFromMap returns a new tree containing the keys from an existing map
func (*Tree) Delete ¶
Delete is used to delete a key, returning the previous value and if it was deleted
func (*Tree) DeletePrefix ¶
DeletePrefix is used to delete the subtree under a prefix Returns how many nodes were deleted Use this to delete large subtrees efficiently
func (*Tree) Insert ¶
Insert is used to add a newentry or update an existing entry. Returns if updated.
func (*Tree) LongestPrefix ¶
LongestPrefix is like Get, but instead of an exact match, it will return the longest prefix match.
func (*Tree) 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 (*Tree) WalkPrefix ¶
WalkPrefix is used to walk the tree under a prefix
type ValueFactory ¶
type ValueFactory func(key string) Exportable
ValueFactory is a factory function which constructs the object which is to be used to understand the value stored. The key will be passed to this routine, so we should be able to construct different objects based on different keys