trie

package
v1.0.50 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InvalidString = errors.New("InvalidString")

Functions

This section is empty.

Types

type OnMatch

type OnMatch[T any] func(t *T) bool

type TrieNode

type TrieNode[T any] struct {
	Data *T

	Key string
	// contains filtered or unexported fields
}

TrieNode trie Node

func NewTrie

func NewTrie[T any]() *TrieNode[T]

NewTrie create a new trie tree

func (*TrieNode[T]) AddData

func (t *TrieNode[T]) AddData(key string, data *T) error

AddData add data

func (*TrieNode[T]) Find

func (t *TrieNode[T]) Find(key string) *TrieNode[T]

Find walk through the tire and return the node that represent the key return nil if not found

func (*TrieNode[T]) GetMatchedData

func (t *TrieNode[T]) GetMatchedData(filter string) []*T

func (*TrieNode[T]) LoopKey added in v1.0.47

func (t *TrieNode[T]) LoopKey(key string, fn OnMatch[T])

LoopKey walk through the tire and call the fn callback for each message witch match the key filter.

func (*TrieNode[T]) MatchKey

func (t *TrieNode[T]) MatchKey(keySlice []string, fn OnMatch[T])

MatchKey walk through the tire and call the fn callback for each message witch match the key filter.

func (*TrieNode[T]) NewChild

func (t *TrieNode[T]) NewChild() *TrieNode[T]

NewChild create a child node of t

func (*TrieNode[T]) Remove

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

Jump to

Keyboard shortcuts

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