setz

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMapKeysToSet

func AddMapKeysToSet[T comparable, V any](s Set[T], m map[T]V)

AddMapKeysToSet adds all keys in m to s.

func AddMapValuesToSet

func AddMapValuesToSet[T comparable, K comparable](s Set[T], m map[K]T)

AddMapValuesToSet adds all values in m to s.

Types

type Bitmap added in v0.0.20

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

func (*Bitmap) Add added in v0.0.20

func (b *Bitmap) Add(num uint) bool

Add adds a number to the set.

func (*Bitmap) Cap added in v0.0.20

func (b *Bitmap) Cap() int

Cap returns the capacity of the set.

func (*Bitmap) Contains added in v0.0.20

func (b *Bitmap) Contains(num uint) bool

Contains returns true if the set contains the number.

func (*Bitmap) Grow added in v0.0.20

func (b *Bitmap) Grow(n uint)

Grow grows the set to the given size.

func (*Bitmap) Iter added in v0.0.20

func (b *Bitmap) Iter() BitsIter

Iter returns a new BitsIter.

func (*Bitmap) Len added in v0.0.20

func (b *Bitmap) Len() int

Len returns the length of the set.

func (*Bitmap) Range added in v0.0.20

func (b *Bitmap) Range(fn func(uint) bool)

Range calls fn for each number in the set.

func (*Bitmap) Remove added in v0.0.20

func (b *Bitmap) Remove(num uint) bool

Remove removes a number from the set.

func (*Bitmap) String added in v0.0.20

func (b *Bitmap) String() string

String returns a string representation of the set.

type Bits

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

Bits is a set of bits.

func (*Bits) Add

func (b *Bits) Add(num uint) bool

Add adds a number to the set.

func (*Bits) All

func (b *Bits) All() iter.Seq[uint]

All returns an iterator that yields all values in the bit set.

func (*Bits) Len

func (b *Bits) Len() int

Len returns the length of the set.

func (*Bits) Remove

func (b *Bits) Remove(num uint) bool

Remove removes a number from the set.

type BitsIter

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

BitsIter is an iterator for Bits.

func (*BitsIter) Next

func (bi *BitsIter) Next() bool

Next returns true if there is a next value.

func (*BitsIter) Value

func (bi *BitsIter) Value() uint

Value returns the current value.

type RoaringBitmap added in v0.0.20

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

func (*RoaringBitmap) Add added in v0.0.20

func (r *RoaringBitmap) Add(num uint32) bool

Add adds a number to the roaring bitmap.

func (*RoaringBitmap) All added in v0.0.20

func (r *RoaringBitmap) All() iter.Seq[uint32]

All returns an iterator that yields all values in the roaring bitmap.

func (*RoaringBitmap) Contains added in v0.0.20

func (r *RoaringBitmap) Contains(num uint32) bool

Contains returns true if the roaring bitmap contains the number.

func (*RoaringBitmap) Iter added in v0.0.20

func (r *RoaringBitmap) Iter() RoaringBitmapIter

Iter returns an iterator for the roaring bitmap.

func (*RoaringBitmap) Len added in v0.0.20

func (r *RoaringBitmap) Len() int

Len returns the number of numbers in the roaring bitmap.

func (*RoaringBitmap) Range added in v0.0.20

func (r *RoaringBitmap) Range(fn func(num uint32) bool)

Range calls fn for each number in the roaring bitmap.

func (*RoaringBitmap) Remove added in v0.0.20

func (r *RoaringBitmap) Remove(num uint32) bool

Remove removes a number from the roaring bitmap.

type RoaringBitmapIter added in v0.0.20

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

func (*RoaringBitmapIter) Next added in v0.0.20

func (i *RoaringBitmapIter) Next() bool

func (*RoaringBitmapIter) Value added in v0.0.20

func (i *RoaringBitmapIter) Value() uint32

type Set

type Set[T comparable] map[T]struct{}

Set[T comparable] is a set of T.

func FromMapKeys

func FromMapKeys[T comparable, V any](src map[T]V) Set[T]

FromMapKeys returns a new set containing all keys in src.

func FromMapValues

func FromMapValues[T comparable, K comparable](m map[K]T) Set[T]

FromMapValues returns a new set containing all values in src.

func FromSlice

func FromSlice[T comparable](src []T) Set[T]

FromSlice returns a new set containing all values in src.

func (Set[T]) Add

func (s Set[T]) Add(v T) (first bool)

Add adds v to s.

func (Set[T]) AddAll

func (s Set[T]) AddAll(vs ...T)

AddAll adds all values in vs to the set.

func (Set[T]) Clear

func (s Set[T]) Clear()

Clear clears s.

func (Set[T]) Delete

func (s Set[T]) Delete(v T) (exists bool)

Delete deletes v from s.

func (Set[T]) Diff

func (s Set[T]) Diff(other Set[T])

Diff deletes all values in s that are also in other.

func (Set[T]) DiffWithSlice

func (s Set[T]) DiffWithSlice(other []T)

DiffWithSlice deletes all values in s that are also in other.

func (Set[T]) Filter

func (s Set[T]) Filter(fn func(T) bool)

Filter deletes all values in s that do not satisfy fn.

func (Set[T]) Has

func (s Set[T]) Has(v T) bool

Has reports whether v is in s.

func (Set[T]) Intersect

func (s Set[T]) Intersect(other Set[T])

Intersect deletes all values in s that are not in other.

func (Set[T]) IntersectWithSlice

func (s Set[T]) IntersectWithSlice(other []T)

IntersectWithSlice deletes all values in s that are not in other.

func (Set[T]) Len

func (s Set[T]) Len() int

Len returns the length of s.

func (Set[T]) Merge

func (s Set[T]) Merge(other Set[T])

Merge adds all values in other to s.

func (Set[T]) Range

func (s Set[T]) Range(fn func(T))

Range calls fn sequentially for each value present in the set.

func (Set[T]) Values

func (s Set[T]) Values(dst []T) []T

Values returns all values in s.

Jump to

Keyboard shortcuts

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