trie

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

https://github.com/derekparker/trie/blob/v3/trie.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByKeys

type ByKeys []string

func (ByKeys) Len

func (a ByKeys) Len() int

func (ByKeys) Less

func (a ByKeys) Less(i, j int) bool

func (ByKeys) Swap

func (a ByKeys) Swap(i, j int)

type Node

type Node[T any] interface {
	Value() T
}

type Trie

type Trie[T any] struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Trie is safe for concurrent use.

func New

func New[T any]() *Trie[T]

func (*Trie[T]) Add

func (t *Trie[T]) Add(key string, value T) Node[T]

func (*Trie[T]) Find

func (t *Trie[T]) Find(key string) (Node[T], bool)

func (*Trie[T]) FuzzySearch

func (t *Trie[T]) FuzzySearch(pre string) []string

FuzzySearch returns, sorted, keys containing pre's runes in order (a subsequence match).

func (*Trie[T]) HasKeysWithPrefix

func (t *Trie[T]) HasKeysWithPrefix(key string) bool

func (*Trie[T]) Keys

func (t *Trie[T]) Keys() []string

Keys returns an empty, non-nil slice for an empty trie.

func (*Trie[T]) PrefixSearch

func (t *Trie[T]) PrefixSearch(pre string) []string

PrefixSearch returns nil when no key has the prefix.

func (*Trie[T]) Remove

func (t *Trie[T]) Remove(key string)

Jump to

Keyboard shortcuts

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