Documentation ¶
Overview ¶
Package radixtree a data structure that represents a space-optimized trie (prefix tree) in which each node that is the only child is merged with its parent.
Index ¶
- type KeyValue
- type RadixTree
- func (rt *RadixTree) Contains(key string) (bool, error)
- func (rt *RadixTree) Delete(key string) (bool, error)
- func (rt *RadixTree) Get(key string) (interface{}, error)
- func (rt *RadixTree) IsEmpty() bool
- func (rt *RadixTree) Items() <-chan KeyValue
- func (rt *RadixTree) Keys() <-chan string
- func (rt *RadixTree) KeysWithPrefix(s string) <-chan string
- func (rt *RadixTree) LongestPrefixOf(key string) (string, error)
- func (rt *RadixTree) Put(key string, value interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KeyValue ¶
type KeyValue struct { Key string Value interface{} }
KeyValue is a key value pair from the RadixTree.
type RadixTree ¶
type RadixTree struct {
// contains filtered or unexported fields
}
RadixTree is a external API for the trie.
func (*RadixTree) Contains ¶
Contains returns true if the trie contains the key else returns false. A error is returned if the key has zero length.
func (*RadixTree) Delete ¶
Delete removes the key and value from the tree returns true if the key was found else returns false. A error is returned if the key has zero length.
func (*RadixTree) Get ¶
Get returns the value associated with the key else returns nil. Get returns an error if the key passed has zero length.
func (*RadixTree) KeysWithPrefix ¶
KeysWithPrefix searches the tree for all the keys for which s is a valid prefix. Returns a channel that returns all the keys
func (*RadixTree) LongestPrefixOf ¶
LongestPrefixOf returns the longest prefix of the key found in the trie. A empty string is returned no common prefix is found. A error is returned if the passed key has zero length.