Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node[V any] struct { Value *V Right *Node[V] Left *Node[V] // contains filtered or unexported fields }
Node represents trie node which may contains a prefix if node has prefix it will have non-nil prefix value and otherwise it will have nil prefix value.
type Trie ¶
type Trie[V any] struct { Root *Node[V] Height uint Prefix string // when trie is subtrie this field represents old prefix of root }
Trie represents binary trie for prefix lookup.
func (*Trie[V]) Add ¶
Add adds new route into trie. Given route must be in binary regex format e.g. *, 11*.
func (*Trie[V]) Divide ¶
Divide divides the binary trie into different levels based on these k-bit subtries. If k = 4 thus, level 0 contains from prefix length 0 to prefix length 7, and so on. Each level contains one or more subtries. nolint: funlen, gocognit, cyclop
func (*Trie[V]) Lookup ¶
Lookup looks up given route in trie and returns found value. Given route must be in binary representation e.g. 111111..