Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node struct { NextHop string Right *Node Left *Node // 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 struct { Root *Node Height uint Prefix string // when trie is subtrie this field represents old prefix of root }
Trie represents binary trie for IP route lookup.
func NewFromArray ¶
NewFromArray creates new trie based on given node array with following structure.
i / \ 2i 2i+1
func (*Trie) Add ¶
Add adds new route into trie given route must be in binary regex format e.g. *, 11*.
func (*Trie) 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
Click to show internal directories.
Click to hide internal directories.