package module
v1.0.2 Latest Latest

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

Go to latest
Published: Sep 28, 2019 License: MIT Imports: 11 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type Leafs

type Leafs []*PlainLeaf

sorter interface

func (Leafs) Len

func (slice Leafs) Len() int

func (Leafs) Less

func (slice Leafs) Less(i, j int) bool

func (Leafs) Swap

func (slice Leafs) Swap(i, j int)

type PlainLeaf

type PlainLeaf struct {
	Value    string
	Category string
	Weight   float64

func (*PlainLeaf) String

func (m *PlainLeaf) String() string

type Trie added in v1.0.2

type Trie struct {
	// contains filtered or unexported fields

func LoadFromFile

func LoadFromFile(fname string) (tr *Trie, err error)

LoadFromFile loads a gib encoded wordlist from a file and creates a new Trie by Add()ing all of them.

func New

func New() *Trie

NewTrie returns the pointer to a new Trie with an initialized root Branch

func (*Trie) Add added in v1.0.2

func (t *Trie) Add(val, cat string, w float64)

Add adds an entry to the trie

func (*Trie) Find added in v1.0.2

func (t *Trie) Find(prefix string) Leafs

Find returns all entries of the Trie that have the given prefix with their counts as Leaf sorted by weights

func (*Trie) FindFirstN added in v1.0.2

func (t *Trie) FindFirstN(prefix string, n int) Leafs

FindFirstN returns first N results for given prefix sorted by weights

func (*Trie) SaveToFile added in v1.0.2

func (t *Trie) SaveToFile(fname string) (err error)

SaveToFile dumps all values into a slice of strings and writes that to a file using encoding/gob.

The Trie itself can currently not be encoded directly because gob does not directly support structs with a sync.Mutex on them.

Jump to

Keyboard shortcuts

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