bitwise

package
v0.0.0-...-4573a4b Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitSet

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

BitSet is a set of bits.

func NewBitSet

func NewBitSet(capacity uint) BitSet

NewBitSet returns a new BitSet with the given capacity.

func (BitSet) Capacity

func (s BitSet) Capacity() uint

Capacity returns the capacity of the BitSet.

func (BitSet) Count

func (s BitSet) Count() (count uint)

Count returns the number of bits set to 1.

func (*BitSet) Flip

func (s *BitSet) Flip(index uint)

Flip flips the bit at the given index.

func (*BitSet) FlipAll

func (s *BitSet) FlipAll()

FlipAll flips all bits.

func (BitSet) IsSet

func (s BitSet) IsSet(index uint) bool

IsSet returns whether the bit at the given index is set to 1.

func (*BitSet) Set

func (s *BitSet) Set(index uint)

Set sets the bit at the given index to 1.

func (*BitSet) SetAll

func (s *BitSet) SetAll()

SetAll sets all bits to 1.

func (*BitSet) Unset

func (s *BitSet) Unset(index uint)

Unset sets the bit at the given index to 0.

func (*BitSet) UnsetAll

func (s *BitSet) UnsetAll()

UnsetAll sets all bits to 0.

type SlidingWindowFilter

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

SlidingWindowFilter maintains a sliding window of uint64 counters.

func NewSlidingWindowFilter

func NewSlidingWindowFilter(size uint64) *SlidingWindowFilter

NewSlidingWindowFilter returns a new sliding window filter with the given size.

func (*SlidingWindowFilter) Add

func (f *SlidingWindowFilter) Add(counter uint64) bool

Add attempts to add counter to the sliding window and returns whether the counter is successfully added to the sliding window.

func (*SlidingWindowFilter) IsOk

func (f *SlidingWindowFilter) IsOk(counter uint64) bool

IsOk checks whether counter can be accepted by the sliding window filter.

func (*SlidingWindowFilter) MustAdd

func (f *SlidingWindowFilter) MustAdd(counter uint64)

MustAdd adds counter to the sliding window without checking if the counter is valid. Call IsOk beforehand to make sure the counter is valid.

func (*SlidingWindowFilter) Reset

func (f *SlidingWindowFilter) Reset()

Reset resets the filter to its initial state.

func (*SlidingWindowFilter) Size

func (f *SlidingWindowFilter) Size() uint64

Size returns the size of the sliding window.

Jump to

Keyboard shortcuts

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