trie

package
v0.0.0-...-8983f9b Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Extension = searchResult(1)
	Greater   = searchResult(2)
	Less      = searchResult(3)
	Matched   = searchResult(4)
	Prefix    = searchResult(5)
	Unmatched = searchResult(6)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Digitizer

type Digitizer interface {

	// Base returns the base for the Digitizer.
	Base() int

	// IsPrefixFree returns true if and only if the Digitizer guarantees that no element is a prefix of another.
	IsPrefixFree() bool

	// NumDigitsOf returns the number of digits in the provided element.
	NumDigitsOf(element interface{}) int

	// DigitOf returns the element of digit place for the provided element.
	DigitOf(element interface{}, place int) int

	// FormatDigit returns a string representation of the digit in the place specified for the given element.
	FormatDigit(element interface{}, place int) string
}

Digitizer

func NewStringDigitizer

func NewStringDigitizer(alphabetSize int) Digitizer

NewStringDigitizer creates a new Digitizer for strings with the provided alphabet size.

type LeafNode

type LeafNode interface {
	Node

	AddAfter(leafNode LeafNode)
	SetNext(next LeafNode)
	Next() LeafNode
	SetPrevious(previous LeafNode)
	Previous() LeafNode
	IsDeleted() bool
	Remove()
	IsHead() bool
	IsTail() bool
}

LeafNode

type Node

type Node interface {
	SetParent(parent Node)
	Parent() Node
	AddChildWithIndexOf(index int, child Node) error
	ChildWithIndexOf(index int) (Node, error)
	RemoveChildWithIndexOf(index int) bool
	HasChildren() bool
	SetValue(element interface{})
	Value() interface{}
	IsRoot() bool
	IsLeaf() bool
}

Node

type Trie

type Trie interface {
	collection.Ordered

	// Completions finds all elements in the Trie that match the provided prefix, and appends the matching elements
	// (if any) to the provided collection.
	Completions(prefix interface{}, collection collection.Collection)

	// LongestCommonPrefix finds all elements in the Trie that share the longest common prefix with the provided
	// element, and appends the matching elements (if any) to the provided collection.
	LongestCommonPrefix(element interface{}, collection collection.Collection)
}

Trie

func NewRadixTree

func NewRadixTree(capacity int) Trie

NewRadixTree

func NewRadixTreeWithDigitizer

func NewRadixTreeWithDigitizer(digitizer Digitizer) Trie

NewRadixTreeWithDigitizer

func NewTrie

func NewTrie(capacity int) Trie

NewTrie creates a new Trie with the provided capacity. The capacity is used to set the base (or range of digits) used by the StringDigitizer for the trie. The base of the StringDigitizer is used to set the number of children each Node within the trie has.

func NewTrieWithDigitizer

func NewTrieWithDigitizer(digitizer Digitizer) Trie

NewTrieWithDigitizer

Jump to

Keyboard shortcuts

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