Documentation
¶
Index ¶
- type Node
- type Prefix
- type PrefixCallback
- type PrefixMap
- func (m *PrefixMap) Contains(key string) bool
- func (m *PrefixMap) ContainsPrefix(key string) bool
- func (m *PrefixMap) EachPrefix(callback PrefixCallback)
- func (m *PrefixMap) Get(key string) []interface{}
- func (m *PrefixMap) GetByPrefix(key string) []interface{}
- func (m *PrefixMap) Insert(key string, values ...interface{})
- func (m *PrefixMap) Replace(key string, values ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node struct { // true if this node is a leaf node IsLeaf bool // the reference to the parent node Parent *Node // the children nodes Children []*Node // contains filtered or unexported fields }
Node is a single node within the map
type Prefix ¶
type Prefix struct { // The current prefix string Key string // The values associated to the current prefix Values []interface{} // contains filtered or unexported fields }
Prefix holds prefix information passed to the PrefixCallback instance by the EachPrefifx method.
type PrefixCallback ¶
PrefixCallback is invoked by EachPrefix for each prefix reached by the traversal. The callback has the ability to affect the traversal. Returning skipBranch = true will make the traversal skip the current branch and jump to the sibling node in the map. Returning halt = true, instead, will halt the traversal altogether.
type PrefixMap ¶
type PrefixMap Node
PrefixMap type
func (*PrefixMap) Contains ¶
Contains checks if the given key is present in the map In this case, an exact match case is considered If you're interested in prefix-based check: ContainsPrefix
func (*PrefixMap) ContainsPrefix ¶
ContainsPrefix checks if the given prefix is present as key in the map
func (*PrefixMap) EachPrefix ¶
func (m *PrefixMap) EachPrefix(callback PrefixCallback)
EachPrefix iterates over the prefixes contained in the map using a DFS algorithm. The callback can be used to skip a prefix branch altogether or halt the iteration.
func (*PrefixMap) Get ¶
Get returns the data associated with the given key in the map or nil if no such key is present in the map
func (*PrefixMap) GetByPrefix ¶
GetByPrefix returns a flattened collection of values associated with the given prefix key