Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TrieMap ¶
type TrieMap[V comparable] struct { // contains filtered or unexported fields }
TrieMap contains an efficient trie structure of netip.Prefix that can match a netip.Addr to the associated Prefix if any and return the value associated with it of type V.
Use NewTrieMap to instantiate ¶
Currently this is a simple TrieMap, in the future it may have compression.
See: https://vincent.bernat.ch/en/blog/2017-ipv4-route-lookup-linux
func (*TrieMap[V]) Get ¶
Get returns the associated value for the matching prefix if any with contains=true, or else the default value of V and contains=false.
func (*TrieMap[V]) Insert ¶
Insert inserts value into TrieMap by index prefix. You can later match a netip.Addr to value with Get().
func (*TrieMap[V]) Remove ¶
Remove removes the prefix from the TrieMap. Returns true if the prefix was removed, false if it was not found.
func (*TrieMap[V]) RemoveValue ¶
func (t *TrieMap[V]) RemoveValue(value V)
RemoveValue removes all prefixes with the given value from the TrieMap.