Documentation ¶
Index ¶
- type Bits
- func (b Bits) Add(i int)
- func (b Bits) Bytes() []byte
- func (b Bits) Clear()
- func (b Bits) Contains(i int) bool
- func (b Bits) Difference(other Bits)
- func (b Bits) HammingWeight() int
- func (b Bits) Intersection(other Bits)
- func (b Bits) Len() int
- func (b Bits) Remove(i int)
- func (b Bits) String() string
- func (b Bits) Union(other Bits)
- type Bits64
- type Set
- func (s *Set[T]) Add(elts ...T)
- func (s Set[T]) CappedList(size int) []T
- func (s *Set[_]) Clear()
- func (s *Set[T]) Contains(elt T) bool
- func (s *Set[T]) Difference(set Set[T])
- func (s Set[T]) Equals(other Set[T]) bool
- func (s Set[_]) Len() int
- func (s Set[T]) List() []T
- func (s *Set[_]) MarshalJSON() ([]byte, error)
- func (s *Set[T]) Overlaps(big Set[T]) bool
- func (s *Set[T]) Peek() (T, bool)
- func (s *Set[T]) Pop() (T, bool)
- func (s *Set[T]) Remove(elts ...T)
- func (s *Set[T]) Union(set Set[T])
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bits ¶ added in v1.9.5
type Bits struct {
// contains filtered or unexported fields
}
Bits is a bit-set backed by a big.Int Holds values ranging from [0, INT_MAX] (arch-dependent) Trying to use negative values will result in a panic. This implementation is NOT thread-safe.
func NewBits ¶ added in v1.9.5
NewBits returns a new instance of Bits with bits set to 1.
Invariants: 1. Negative bits will cause a panic. 2. Duplicate bits are allowed but will cause a no-op.
func (Bits) Contains ¶ added in v1.9.5
Contains returns true if the [i]'th bit is 1, and false otherwise
func (Bits) Difference ¶ added in v1.9.5
Difference removes all the elements in [other] from this set
func (Bits) HammingWeight ¶ added in v1.9.5
HammingWeight returns the amount of 1's in the bitset
func (Bits) Intersection ¶ added in v1.9.5
Intersection performs the set intersection with another set This sets [b] to include only elements in both [b] and [other]
type Bits64 ¶ added in v1.9.5
type Bits64 uint64
Bits64 is a set that can contain uints in the range [0, 64). All functions are O(1). The zero value is the empty set.
func (*Bits64) Clear ¶ added in v1.9.5
func (b *Bits64) Clear()
Clear removes all elements from this set
func (Bits64) Contains ¶ added in v1.9.5
Contains returns true if [i] was previously added to this set
func (*Bits64) Difference ¶ added in v1.9.5
Difference removes all the elements in [s] from this set
func (*Bits64) Intersection ¶ added in v1.9.5
Intersection takes the intersection of [s] with this set
type Set ¶
type Set[T comparable] map[T]struct{}
Set is a set of elements.
func NewSet ¶
func NewSet[T comparable](size int) Set[T]
Return a new set with initial capacity [size]. More or less than [size] elements can be added to this set. Using NewSet() rather than Set[T]{} is just an optimization that can be used if you know how many elements will be put in this set.
func (*Set[T]) Add ¶
func (s *Set[T]) Add(elts ...T)
Add all the elements to this set. If the element is already in the set, nothing happens.
func (Set[T]) CappedList ¶
CappedList returns a list of length at most [size]. Size should be >= 0. If size < 0, returns nil.
func (*Set[T]) Difference ¶
Difference removes all the elements in set from [s].
func (*Set[_]) MarshalJSON ¶
func (*Set[T]) Pop ¶
Removes and returns an element. If the set is empty, does nothing and returns false.