patriciaDB

package
v0.0.0-...-613b6cb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxPrefixPerNode         = 4
	DefaultMaxChildrenPerSparseNode = 2
)

Variables

View Source
var (
	SkipSubtree  = errors.New("Skip this subtree")
	ErrNilPrefix = errors.New("Nil prefix passed into a method call")
)

Functions

This section is empty.

Types

type Item

type Item interface{}

type Prefix

type Prefix []byte

type Trie

type Trie struct {
	// contains filtered or unexported fields
}

func NewTrie

func NewTrie() *Trie

func (*Trie) Delete

func (trie *Trie) Delete(key Prefix) (deleted bool)

Delete deletes the item represented by the given prefix.

True is returned if the matching node was found and deleted.

func (*Trie) Get

func (trie *Trie) Get(key Prefix) (item Item)

Get returns the item located at key.

func (*Trie) GetLongestPrefixNode

func (trie *Trie) GetLongestPrefixNode(prefix Prefix) (item Item)

func (*Trie) Insert

func (trie *Trie) Insert(key Prefix, item Item) (inserted bool)

Insert inserts a new item into the trie using the given prefix. Insert does not replace existing items. It returns false if an item was already in place.

func (*Trie) Item

func (trie *Trie) Item() Item

Item returns the item stored in the root of this trie.

func (*Trie) Match

func (trie *Trie) Match(prefix Prefix) (matchedExactly bool)

Match returns what Get(prefix) != nil would return. The same warning as for Get applies here as well.

func (*Trie) Set

func (trie *Trie) Set(key Prefix, item Item)

Set works much like Insert, but it always sets the item, possibly replacing the item previously inserted.

func (*Trie) Visit

func (trie *Trie) Visit(visitor VisitorFunc) error

Visit calls visitor on every node containing a non-nil item in alphabetical order.

func (*Trie) VisitAndUpdate

func (trie *Trie) VisitAndUpdate(visitor UpdateFunc, handle Item) error

Visit calls visitor on every node containing a non-nil item in alphabetical order.

type UpdateFunc

type UpdateFunc func(prefix Prefix, item Item, handle Item) error

type VisitorFunc

type VisitorFunc func(prefix Prefix, item Item) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL