lpm

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package lpm (longest-prefix-match) contains the lookup table with which the backtracking for the lpm in the complete binary tree of the prefixes can be replaced by a fast bitset operation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackTrackingBitset

func BackTrackingBitset(idx uint) *bitset.BitSet256

BackTrackingBitset is the backtracking sequence in the complete binary tree of the prefixes (mapped by the base_index function) as bitstring.

for idx := 1; idx > 0; idx >>= 1 { b.Set(idx) }

allows a one shot bitset intersection algorithm:

func (n *node[V]) lpmTest(idx uint) bool {
	return n.prefixes.IntersectsAny(lpmbt.LookupTbl[idx])
}

instead of a sequence of single bitset tests:

func (n *node[V]) lpmTest(idx uint) bool {
	for ; idx > 0; idx >>= 1 {
		if n.prefixes.Test(idx) {
			return true
		}
	}
	return false
}

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL