trie

package
v0.6.9 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const WildCardChar = '*' // 通配符

Variables

This section is empty.

Functions

This section is empty.

Types

type Map added in v0.3.4

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

rune trie map

func NewMap added in v0.3.4

func NewMap() *Map

func (*Map) Contains added in v0.3.4

func (m *Map) Contains(key string) bool

Contains returns true if map has the given key stored

func (*Map) Delete added in v0.3.4

func (m *Map) Delete(key string) bool

Delete removes the value associated with the given key.

func (*Map) Get added in v0.3.4

func (m *Map) Get(key string) interface{}

Get returns the value stored at the given key

func (*Map) HasKeyWithPrefix added in v0.3.4

func (m *Map) HasKeyWithPrefix(prefix string) bool

func (*Map) KeysWithPattern added in v0.3.4

func (m *Map) KeysWithPattern(pattern string) []string

KeysWithPattern("t*a*") -> ["team", "that"]

func (*Map) KeysWithPrefix added in v0.3.4

func (m *Map) KeysWithPrefix(prefix string) []string

KeysWithPrefix find all words with prefix `prefix` keysWithPrefix("th") -> ["that", "the", "them"]

func (*Map) LongestPrefixOf added in v0.3.4

func (m *Map) LongestPrefixOf(query string) string

LongestPrefixOf find longtest prefix of `query` ['the','them'] LongestPrefixOf("themxyz") -> "them"

func (*Map) Put added in v0.3.4

func (m *Map) Put(key string, v interface{}) bool

Put inserts the value into the trie at the given key, replacing any existing items.

func (*Map) PutIfAbsent added in v0.3.4

func (m *Map) PutIfAbsent(key string, v interface{}) bool

PutIfAbsent inserts the value into the trie at the given key only when key not exists.

func (*Map) ShortestPrefixOf added in v0.3.4

func (m *Map) ShortestPrefixOf(query string) string

ShortestPrefixOf find shortest prefix of `query` ['the','them'] ShortestPrefixOf("themxyz") -> "the"

func (*Map) Size added in v0.3.4

func (m *Map) Size() int

func (*Map) Walk added in v0.3.4

func (m *Map) Walk(action WalkAction) error

Walk iterates over each key/value stored in the trie and calls the given walker function with the key and value. If the walker function returns an error, the walk is aborted.

type Node added in v0.3.4

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

trie map node

func (*Node) IsLeaf added in v0.3.4

func (n *Node) IsLeaf() bool

func (*Node) Walk added in v0.3.4

func (n *Node) Walk(path string, action WalkAction) error

type WalkAction added in v0.3.4

type WalkAction func(key string, value interface{}) error

WalkAction defines some action to take on the given key and value during a Trie Walk. Returning a non-nil error will terminate the Walk.

Jump to

Keyboard shortcuts

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