trie

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2016 License: BSD-3-Clause Imports: 1 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByKeys

type ByKeys []string

ByKeys type cast for string array

func (ByKeys) Len

func (a ByKeys) Len() int

Len of keys

func (ByKeys) Less

func (a ByKeys) Less(i, j int) bool

Less checks if key i is less than j to determine position

func (ByKeys) Swap

func (a ByKeys) Swap(i, j int)

Swap keys to reorder

type Node

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

Node struct

func (Node) Children

func (n Node) Children() map[rune]*Node

Children returns the children of this node.

func (Node) Mask

func (n Node) Mask() uint64

Mask returns a uint64 representing the current mask of this node.

func (Node) Meta

func (n Node) Meta() interface{}

Meta returns the meta information of this node.

func (*Node) NewChild

func (n *Node) NewChild(val rune, bitmask uint64, meta interface{}, term bool) *Node

NewChild creates and returns a pointer to a new child for the node.

func (Node) Parent

func (n Node) Parent() *Node

Parent returns the parent of this node.

func (*Node) RemoveChild

func (n *Node) RemoveChild(r rune)

RemoveChild from list

func (Node) Val

func (n Node) Val() rune

Val returns the value of the node as a rune

type Trie

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

Trie struct

func New

func New() *Trie

New Trie with an initialized root Node.

func (*Trie) Add

func (t *Trie) Add(key string, meta interface{}) *Node

Add the key to the Trie, including meta data. Meta data is stored as `interface{}` and must be type cast by the caller.

func (*Trie) Find

func (t *Trie) Find(key string) (*Node, bool)

Find and returns meta data associated with `key`.

func (Trie) FuzzySearch

func (t Trie) FuzzySearch(pre string) []string

FuzzySearch performs a fuzzy search against the keys in the trie.

func (*Trie) Keys

func (t *Trie) Keys() []string

Keys will return all the keys currently stored in the trie.

func (Trie) PrefixSearch

func (t Trie) PrefixSearch(pre string) []string

PrefixSearch performs a prefix search against the keys in the trie.

func (*Trie) Remove

func (t *Trie) Remove(key string)

Remove a key from the trie, ensuring that all bitmasks up to root are appropriately recalculated.

func (*Trie) Root

func (t *Trie) Root() *Node

Root returns the root node for the Trie.

Jump to

Keyboard shortcuts

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