dbitset

package
v0.0.0-...-e2998bb Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package dbitset contains dragon-specific utilities around bitsets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandomClearBitIterator

func RandomClearBitIterator(bs *bitset.BitSet) iter.Seq[*ClearBit]

RandomClearBitIterator iterates over the cleared bits in bs in a pseudorandom order. The ClearBit return type has an *ClearBit.InPlaceUnion method which can be used to avoid iterating certain bits in this sequence of the current iteration.

func RandomSetBitIterator

func RandomSetBitIterator(bs *bitset.BitSet) iter.Seq[*SetBit]

Types

type AdaptiveDecoder

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

func (*AdaptiveDecoder) ReceiveBitset

func (d *AdaptiveDecoder) ReceiveBitset(
	s quic.ReceiveStream,
	timeout time.Duration,
	bs *bitset.BitSet,
) error

type AdaptiveEncoder

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

func (*AdaptiveEncoder) SendBitset

func (e *AdaptiveEncoder) SendBitset(
	s quic.SendStream,
	timeout time.Duration,
	bs *bitset.BitSet,
) error

type ClearBit

type ClearBit struct {
	Idx uint
	// contains filtered or unexported fields
}

ClearBit is the type returned in the RandomClearBitIterator. This is a dedicated type as opposed to a simple uint in order to expose the *ClearBit.InPlaceUnion method.

func (*ClearBit) InPlaceUnion

func (b *ClearBit) InPlaceUnion(x *bitset.BitSet)

InPlaceUnion updates b to be the union of b and x. The input argument is not modified or retained. Any set bits in x will be skipped in following iterations through b.

In most use cases there will be a separate "tracking" bitset that also needs updated.

type CombinationDecoder

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

CombinationDecoder maintains internal state for decoding compressed bitsets. This internal state reduces allocations as bitsets are decoded.

The zero value of CombinationDecoder is ready to use.

CombinationDecoder is not safe for concurrent use.

func (*CombinationDecoder) ReceiveBitset

func (d *CombinationDecoder) ReceiveBitset(
	s quic.ReceiveStream,
	timeout time.Duration,
	bs *bitset.BitSet,
) error

ReceiveBitset reads a compressed bitset from the given stream, and sets the bs input argument to match that value.

The read deadline for the bitset is determined by the timeout argument. If timeout is positive, that duration is used for the deadline. Otherwise, the read deadline is cleared and the read will block until the data is received or the read is canceled.

The bitset's length (as reported by *bitset.BitSet.Len) must be the same value the remote expects, or else the remote will decode a different value from what we encode here.

type CombinationEncoder

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

CombinationEncoder maintains internal state for encoding compressed bitsets. This internal state reduces allocations as bitsets are encoded.

The zero value of CombinationEncoder is ready to use.

CombinationEncoder is not safe for concurrent use.

func (*CombinationEncoder) SendBitset

func (e *CombinationEncoder) SendBitset(
	s quic.SendStream,
	timeout time.Duration,
	bs *bitset.BitSet,
) error

SendBitset writes the compressed form of bs to the given stream. The bitset's length (as reported by *bitset.BitSet.Len) must be the same value the remote expects, or else the remote will decode a different value from what we encode here.

type RawDecoder

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

func (*RawDecoder) ReceiveBitset

func (d *RawDecoder) ReceiveBitset(
	s quic.ReceiveStream,
	timeout time.Duration,
	bs *bitset.BitSet,
) error

type RawEncoder

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

func (*RawEncoder) SendBitset

func (e *RawEncoder) SendBitset(
	s quic.SendStream,
	timeout time.Duration,
	bs *bitset.BitSet,
) error

type SetBit

type SetBit struct {
	Idx uint
}

SetBit is the type returned by RandomSetBitIterator.

type SnappyDecoder

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

func (*SnappyDecoder) ReceiveBitset

func (d *SnappyDecoder) ReceiveBitset(
	s quic.ReceiveStream,
	timeout time.Duration,
	bs *bitset.BitSet,
) error

type SnappyEncoder

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

func (*SnappyEncoder) SendBitset

func (e *SnappyEncoder) SendBitset(
	s quic.SendStream,
	timeout time.Duration,
	bs *bitset.BitSet,
) error

Jump to

Keyboard shortcuts

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