art

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 art summarizes the functions and inverse functions for mapping between a prefix and a baseIndex.

can inline HostIdx with cost 5
can inline IdxToPfx256 with cost 37
can inline IdxToRange256 with cost 61
can inline NetMask with cost 7
can inline PfxLen256 with cost 18
can inline PfxToIdx256 with cost 29
can inline pfxToIdx with cost 11

Please read the ART paper ./doc/artlookup.pdf to understand the baseIndex algorithm.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HostIdx

func HostIdx(octet uint8) uint

HostIdx is just PfxToIdx(octet/8) but faster.

func IdxToPfx256

func IdxToPfx256(idx uint8) (octet, pfxLen uint8)

IdxToPfx256 returns the octet and prefix len of baseIdx. It's the inverse to pfxToIdx256.

It panics on invalid input.

func IdxToRange256

func IdxToRange256(idx uint8) (first, last uint8)

IdxToRange256 returns the first and last octet of prefix idx.

func NetMask

func NetMask(bits uint8) uint8

NetMask for bits

0b0000_0000, // bits == 0
0b1000_0000, // bits == 1
0b1100_0000, // bits == 2
0b1110_0000, // bits == 3
0b1111_0000, // bits == 4
0b1111_1000, // bits == 5
0b1111_1100, // bits == 6
0b1111_1110, // bits == 7
0b1111_1111, // bits == 8

func PfxLen256

func PfxLen256(depth int, idx uint8) uint8

PfxLen256 returns the bits based on depth and idx.

func PfxToIdx256

func PfxToIdx256(octet, pfxLen uint8) uint8

PfxToIdx256 maps 8bit prefixes to numbers. The values range [1 .. 255]. Values > 255 are shifted by >> 1.

Types

This section is empty.

Jump to

Keyboard shortcuts

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