Documentation
¶
Index ¶
Constants ¶
View Source
const ( MaxPrefixLenIPv4 = 32 MaxPrefixLenIPv6 = 128 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Key ¶
Key is the key of the trie. A key is a byte array with a prefix length. The prefix length is the number of bits for the key. The length of the byte array must be same with eighth of trie's max prefix length.
type LpmTrie ¶
type LpmTrie interface { // Size returns the number of entries in the trie. Size() int64 // Lookup lookups the value of the key by LPM algo. // The length of key's data must be same with eighth of trie's max prefix length, // or it will panic. Lookup(key Key) (interface{}, bool) // Update updates the value of the key by LPM algo. // If the key is not found, it inserts the key-value pair. // The length of key's data must be same with eighth of trie's max prefix length, // or it will panic. Update(key Key, val interface{}) (updated bool) // Delete deletes the key-value pair by LPM algo. // The length of key's data must be same with eighth of trie's max prefix length, // or it will panic. Delete(key Key) (deleted bool) // Range iterates over the key-value pairs in the trie by in-order. Range(fn func(key Key, val interface{}) bool) }
LpmTrie is a trie data structure which implements Longest Prefix Match algorithm.
Click to show internal directories.
Click to hide internal directories.