Documentation ¶
Index ¶
Constants ¶
View Source
const ( //NodeTypeValue value type NodeTypeValue = uint8(2) //NodeTypeEdge edge type NodeTypeEdge = uint8(4) )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bytes ¶
type Bytes []byte
Bytes represents byte slice
func (Bytes) LastSharedIndex ¶
LastSharedIndex computes the last prefix shared indexed
type KeyProvider ¶
type KeyProvider interface {
Key() interface{}
}
KeyProvider represents entity key provider
type Merger ¶
type Merger[T any] func(previous, next T) (merged T)
Merger represents node value merger
type Node ¶
type Node[T any] struct { Type uint8 ValueIndex uint32 Prefix []byte //24 Nodes[T] //24 // contains filtered or unexported fields }
Node represents a node
type Nodes ¶
Nodes represents node slice
type OnMatch ¶
OnMatch represents matching input handler, return value instruct trie to continue search
type Trie ¶
type Trie[T any] interface { Put(key []byte, value T) error Merge(key []byte, value T, merger Merger[T]) error Get(key []byte) (T, bool) Has(key []byte) bool //Walk all tries value nodes. Walk(handler Visitor[T]) //MatchPrefix matches input prefix, ie. input: dev.domain.com, would match with trie keys like: dev, dev.domain MatchPrefix(input []byte, handler OnMatch[T]) bool //MatchAll matches input with any occurrences of tries keys. MatchAll(input []byte, handler OnMatch[T]) bool UseType(vType reflect.Type) //Decode decodes concurrently trie nodes and values Decode(reader io.Reader) error //DecodeSequentially decode sequentially trie nodes and values DecodeSequentially(reader io.Reader) error Encode(writer io.Writer) error ValueCount() int Write(writer io.Writer) error Read(reader io.Reader) error Root() *Node[T] }
Trie represents prefix tree interface
Click to show internal directories.
Click to hide internal directories.