trie

package
v0.78.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Trie implements a byte trie data structure. It is fast as it uses arrays instead of maps and no bound checks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Trie

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

func NewTrie

func NewTrie() *Trie

func (*Trie) All

func (t *Trie) All(prefix string) (int, []string)

All returns all the valid words from that point onwards. Typically called from the result of [Prefix]. if somehow both 0 and 255 are valid yet not much in between, the optimization of min,max range won't do much, but for normal words, it should help a lot. Returns the len of the longest common prefix. If the input is incomplete UTF-8 sequence, use AllBytes() instead.

func (*Trie) AllBytes added in v0.40.0

func (t *Trie) AllBytes(prefix []byte) (int, []string)

func (*Trie) Contains

func (t *Trie) Contains(word string) bool

func (*Trie) Insert

func (t *Trie) Insert(word string)

func (*Trie) IsLeaf

func (t *Trie) IsLeaf() bool

func (*Trie) IsValid

func (t *Trie) IsValid() bool

func (*Trie) Prefix

func (t *Trie) Prefix(word string) *Trie

func (*Trie) PrefixAll

func (t *Trie) PrefixAll(prefix string) (int, []string)

Returns all the matches for the given prefix and the length of the longest common prefix.

Jump to

Keyboard shortcuts

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