trie

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2015 License: Apache-2.0, MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NumericStart = 0
	NumericEnd   = 9
	NumericOther = (NumericEnd - NumericStart) + 1
)
View Source
var AsciiAlphabet = &alphabet{
	min:          0,
	max:          255,
	alphabetizer: indexResolver(asciiAlphabetizer),
}
View Source
var NumericAlphabet = &alphabet{
	min:          NumericStart,
	max:          NumericOther + 1,
	alphabetizer: indexResolver(numericAlphabetizer),
}

Functions

func HasEOS

func HasEOS(t *TrieNode) bool

func PotentialDir

func PotentialDir(t *TrieNode) bool

func PotentialTerminalDir

func PotentialTerminalDir(t *TrieNode) bool

Types

type Trie

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

func New

func New(alphabetizer *alphabet) *Trie

func (*Trie) Apply

func (t *Trie) Apply(f func(*TrieNode))

func (*Trie) BreadthFirstApply

func (t *Trie) BreadthFirstApply(apply func(interface{}))

func (*Trie) BreadthFirstWalk added in v0.2.5

func (t *Trie) BreadthFirstWalk(levelApply func([]interface{})) (bch chan interface{})

func (*Trie) Get

func (t *Trie) Get(key string) (value interface{}, ok bool)

func (*Trie) Match

func (t *Trie) Match(pass func(*TrieNode) bool) (matches chan *TrieNode)

func (*Trie) MatchAndHarvest

func (t *Trie) MatchAndHarvest(pass func(*TrieNode) bool) (matches chan *TrieNode)

func (*Trie) Pop

func (t *Trie) Pop(key string) (popd interface{}, ok bool)

func (*Trie) Set

func (t *Trie) Set(key string, value interface{}) (prev interface{})

func (*Trie) Tag

func (t *Trie) Tag(pass func(*TrieNode) bool, tag interface{}) int

func (*Trie) Walk

func (t *Trie) Walk() chan interface{}

type TrieNode

type TrieNode struct {
	Data interface{}
	// Tag should help to annotate a specific feature e.g color, discovered, isDir etc
	Tag      interface{}
	Children *[]*TrieNode
	// Eos(End-Of-Sequence) is designated to terminate a sequence.
	Eos bool
}

func (*TrieNode) EOS

func (tn *TrieNode) EOS() bool

func (*TrieNode) Match

func (tn *TrieNode) Match(pass func(*TrieNode) bool) (matches chan *TrieNode)

Jump to

Keyboard shortcuts

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