trie

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node[T any] struct {
	// contains filtered or unexported fields
}

func (*Node[T]) Count

func (n *Node[T]) Count() int

func (*Node[T]) GetAllLeafs

func (n *Node[T]) GetAllLeafs() []T

func (*Node[T]) Iterate

func (n *Node[T]) Iterate(f func(key string, value T))

type Trie

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

Trie is a simplified version of a Radix tree (https://en.wikipedia.org/wiki/Radix_tree#:~:text=In%20computer%20science%2C%20a%20radix,is%20merged%20with%20its%20parent.) Trie can be used to search for objects based on a key prefix To improve performance, the key is split by a separator instead of a common characters.

func New

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

New creates a new (Radix) Trie

func (*Trie[T]) Insert

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

Insert a new value with given key

func (*Trie[T]) SearchPrefix

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

SearchPrefix search for all values that within the data structure with a given prefix Note that the prefix key will be split by the separator

func (*Trie[T]) Size

func (t *Trie[T]) Size() int

Jump to

Keyboard shortcuts

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