Documentation
¶
Index ¶
- Constants
- type Map
- func (m *Map) Contains(key string) bool
- func (m *Map) Delete(key string) bool
- func (m *Map) Get(key string) interface{}
- func (m *Map) HasKeyWithPrefix(prefix string) bool
- func (m *Map) KeysWithPattern(pattern string) []string
- func (m *Map) KeysWithPrefix(prefix string) []string
- func (m *Map) LongestPrefixOf(query string) string
- func (m *Map) Put(key string, v interface{}) bool
- func (m *Map) PutIfAbsent(key string, v interface{}) bool
- func (m *Map) ShortestPrefixOf(query string) string
- func (m *Map) Size() int
- func (m *Map) Walk(action WalkAction) error
- type Node
- type WalkAction
Constants ¶
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 (*Map) HasKeyWithPrefix ¶ added in v0.3.4
func (*Map) KeysWithPattern ¶ added in v0.3.4
KeysWithPattern("t*a*") -> ["team", "that"]
func (*Map) KeysWithPrefix ¶ added in v0.3.4
KeysWithPrefix find all words with prefix `prefix` keysWithPrefix("th") -> ["that", "the", "them"]
func (*Map) LongestPrefixOf ¶ added in v0.3.4
LongestPrefixOf find longtest prefix of `query` ['the','them'] LongestPrefixOf("themxyz") -> "them"
func (*Map) Put ¶ added in v0.3.4
Put inserts the value into the trie at the given key, replacing any existing items.
func (*Map) PutIfAbsent ¶ added in v0.3.4
PutIfAbsent inserts the value into the trie at the given key only when key not exists.
func (*Map) ShortestPrefixOf ¶ added in v0.3.4
ShortestPrefixOf find shortest prefix of `query` ['the','them'] ShortestPrefixOf("themxyz") -> "the"
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
type WalkAction ¶ added in v0.3.4
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.