radix

package
v0.11.4 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2021 License: Unlicense Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Match added in v0.9.0

type Match struct {
	Node     *Node
	Length   int  // how many matchable characters contributed
	Replaced bool // whether a replacement character contributed
	Separate bool // false if the match came after another caracter (no space/separation) and contains no skipped characters
}

func (Match) EqualsExceptLength added in v0.9.0

func (match Match) EqualsExceptLength(other Match) bool

type Node

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

func (*Node) Data

func (node *Node) Data() uint32

func (*Node) Depth

func (node *Node) Depth() int

func (*Node) Next

func (node *Node) Next(next byte) *Node

func (*Node) Start

func (node *Node) Start() byte

func (*Node) Word

func (node *Node) Word() bool

type Queue

type Queue struct {
	// For correctness, at least longestWord * 2 because some characters turn into 2 matches
	// In reality, there are no profanities that are missed by reducing this to a lower level
	// For performance, should be a power of 2 so that modulo division is faster
	Storage [32]Match
	// contains filtered or unexported fields
}

func (*Queue) Append

func (queue *Queue) Append(match Match)

appends to back

func (*Queue) AppendUnique

func (queue *Queue) AppendUnique(match Match)

appends to back if queue does not already contain node

func (*Queue) Clear

func (queue *Queue) Clear()

func (*Queue) Len

func (queue *Queue) Len() int

func (*Queue) Remove

func (queue *Queue) Remove() (match Match)

removes from front

type Tree

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

func New

func New() Tree

func (*Tree) Add

func (tree *Tree) Add(word string, data uint32)

func (*Tree) Contains

func (tree *Tree) Contains(word string) (contains bool)

func (*Tree) Get

func (tree *Tree) Get(word string) (data uint32)

func (*Tree) Len

func (tree *Tree) Len() (length int)

func (*Tree) Root

func (tree *Tree) Root() *Node

func (*Tree) Traverse

func (tree *Tree) Traverse(callback func(string, uint32))

Preorder

Jump to

Keyboard shortcuts

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