pctrie

package
v0.0.0-...-8d83361 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bitmap

type Bitmap struct {
	// contains filtered or unexported fields
}

Bitmap represents a compact bit array using uint64 words.

func (*Bitmap) Clear

func (b *Bitmap) Clear(i int)

Clear clears the bit at position i.

func (*Bitmap) Get

func (b *Bitmap) Get(i int) bool

Get returns true if the bit at position i is set.

func (*Bitmap) Len

func (b *Bitmap) Len() int

Len returns the number of bits in the bitmap.

func (*Bitmap) Ones

func (b *Bitmap) Ones() iter.Seq[int]

Ones returns an iterator over the indices of all set bits.

func (*Bitmap) Set

func (b *Bitmap) Set(i int)

Set sets the bit at position i.

func (*Bitmap) String

func (b *Bitmap) String() string

String returns a binary string representation of the bitmap.

type PCTrie

type PCTrie[V any] struct {
	Bitmap   *Bitmap
	NextHops [][]*V
	Size     int // Bitmap size
	// contains filtered or unexported fields
}

PCTrie represents prefix-compressed trie data structure.

func New

func New[V any](tr *trie.Trie[V], compSize int) *PCTrie[V]

New creates new prefix-compressed trie. nolint: cyclop, funlen

func (*PCTrie[V]) Lookup

func (pc *PCTrie[V]) Lookup(route string) (V, bool, error)

Lookup looks up given route in pc-trie and returns found value. Given route must be in binary representation e.g. 111111.. Note that this function assumes that given route length is greater than original trie height.

Jump to

Keyboard shortcuts

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