bit128

package
v0.0.0-...-f98563f Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Cap is the maximum possible size for the set.
	Cap = 128

	// Max is the largest value that can be stored.
	Max = 127
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set [2]uint64

Set is fixed-width bitset able to store non-negative `int` values up to 127. The zero value is empty and ready to use.

func All

func All() Set

All returns a set containing all possible values.

func Less

func Less(value int) Set

Less returns a set containing all values smaller than that given.

func More

func More(value int) Set

More returns a set contains all values greater than that given.

func None

func None() Set

None returns an empty set.

func Value

func Value(value int) Set

Value returns a set containing the one value.

func Values

func Values(values ...int) Set

Values returns a set containing the given values.

func (*Set) Add

func (s *Set) Add(value int)

Add puts a value into the set if not already present.

func (Set) And

func (s Set) And(other Set) Set

And returns the set of values common to both sides.

func (Set) AndCount

func (s Set) AndCount(other Set) int

AndCount returns the number of values the set has in common the other.

func (*Set) Assign

func (s *Set) Assign(other Set)

Assign replaces the values with those from another set.

func (*Set) AssignAll

func (s *Set) AssignAll()

AssignAll adds all possible values to the set.

func (*Set) AssignAnd

func (s *Set) AssignAnd(other Set)

AssignAnd assigns the set of values common to both sides.

func (*Set) AssignIff

func (s *Set) AssignIff(other Set)

AssignIff assigns the set of values on both sides, or neither.

func (*Set) AssignImply

func (s *Set) AssignImply(other Set)

AssignImply assigns the set of values on the right side, or not the left.

func (*Set) AssignNone

func (s *Set) AssignNone()

AssignNone removes all values from the set.

func (*Set) AssignNor

func (s *Set) AssignNor(other Set)

AssignNor assigns the set of values absent from both sides.

func (*Set) AssignNot

func (s *Set) AssignNot()

AssignNot assigns the set of absent values.

func (*Set) AssignOr

func (s *Set) AssignOr(other Set)

AssignOr assigns the set of values on either side (or both).

func (*Set) AssignSub

func (s *Set) AssignSub(other Set)

AssignSub assigns the set of values present on the left but not right.

func (*Set) AssignXor

func (s *Set) AssignXor(other Set)

AssignXor assigns the set of values on exactly one side.

func (Set) Compare

func (s Set) Compare(other Set) int

Compare returns 0 if the set are equal, else, for the smallest value whose presence is not the same between the two sets, a positive (negative) number if present in the left (right) hand side.

func (Set) Count

func (s Set) Count() int

Count returns the number of values in the set.

func (Set) Each

func (s Set) Each() iter.Seq[int]

Each loops over the values of the set in ascending order.

func (Set) Equal

func (s Set) Equal(other Set) bool

Equal tests if the set is the same as another.

func (Set) Has

func (s Set) Has(value int) bool

Has reports whether the set holds the value given.

func (Set) HasAll

func (s Set) HasAll(other Set) bool

HasAll reports whether the set holds all values present in another.

func (Set) HasAny

func (s Set) HasAny(other Set) bool

HasAny reports whether the set has any values in common with another.

func (Set) HasNone

func (s Set) HasNone(other Set) bool

HasNone reports whether the set does not have any values in common with another.

func (Set) Iff

func (s Set) Iff(other Set) Set

Iff returns the set of values on both sides, or neither.

func (Set) Imply

func (s Set) Imply(other Set) Set

Imply returns the set of values on the right side, or not the left.

func (Set) IsAll

func (s Set) IsAll() bool

IsAll reports whether the set contains all possible values.

func (Set) IsNone

func (s Set) IsNone() bool

IsNone reports whether the set contains no values.

func (Set) LessCount

func (s Set) LessCount(value int) int

LessCount returns the number of values in the set less than the given value.

func (Set) Max

func (s Set) Max() int

Max returns the largest value in the set. It returns -1 if empty.

func (Set) Min

func (s Set) Min() int

Min returns the smallest value in the set. It returns -1 if empty.

func (Set) MoreCount

func (s Set) MoreCount(value int) int

MoreCount returns the number of values in the set greater than the given value.

func (Set) Nor

func (s Set) Nor(other Set) Set

Nor returns the set of values absent from both sides.

func (Set) Not

func (s Set) Not() Set

Not returns the set of absent values.

func (Set) Or

func (s Set) Or(other Set) Set

Or returns the set of values on either side (or both).

func (Set) Ranges

func (s Set) Ranges() iter.Seq2[int, int]

Ranges loops over contiguous sub-ranges of the set in ascending order. Each iteration produces the first value of the range, and the smallest value greater than that absent from the set.

func (*Set) Remove

func (s *Set) Remove(value int)

Remove deletes a value from the set if present.

func (Set) String

func (s Set) String() string

String returns a human-readable form of the set.

func (Set) Sub

func (s Set) Sub(other Set) Set

Sub returns the set of values present on the left but not right.

func (Set) Xor

func (s Set) Xor(other Set) Set

Xor returns the set of values on exactly one side.

Jump to

Keyboard shortcuts

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