Documentation
¶
Index ¶
- type BitSet
- func (bs *BitSet) Add(n int)
- func (bs *BitSet) AddRange(m, n int)
- func (bs *BitSet) And(other BitSet)
- func (bs *BitSet) AndNot(other BitSet)
- func (bs BitSet) Contains(n int) bool
- func (bs BitSet) Copy() BitSet
- func (bs *BitSet) Delete(n int)
- func (bs *BitSet) DeleteRange(m, n int)
- func (bs BitSet) Empty() bool
- func (bs BitSet) Equal(other BitSet) bool
- func (bs BitSet) Max() int
- func (bs BitSet) Next(m int) int
- func (bs *BitSet) Or(other BitSet)
- func (bs BitSet) Prev(m int) int
- func (bs *BitSet) Reset()
- func (bs *BitSet) Set(other BitSet)
- func (bs BitSet) Size() int
- func (bs BitSet) String() string
- func (bs BitSet) Subset(other BitSet) bool
- func (bs BitSet) Visit(do func(n int) bool) (aborted bool)
- func (bs BitSet) VisitAll(do func(n int))
- func (bs *BitSet) Xor(other BitSet)
- type Word
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BitSet ¶
type BitSet []uint64
BitSet is a set of non-negative integers represented as a slice of uint64 words, where each bit i in word w corresponds to the integer 64*n + i. The words are kept in ascending order, and the set is trimmed to remove trailing zero words.
func New ¶
New creates a new set with the given non-negative elements. If all n are negative, an empty set is created. The elements are stored in ascending order. The zero value of BitSet is an empty set.
func (*BitSet) DeleteRange ¶
DeleteRange removes all integers from m to n-1 (no-op if m>=n).
func (BitSet) Max ¶
Max returns the maximum element of the bitset. If the set is empty, -1 is returned.
func (BitSet) Next ¶
Next returns the next element n, n > m, in the set, or -1 if there is no such element.
func (BitSet) Prev ¶
Prev returns the previous element n, n < m, in the set, or -1 if there is no such element.
func (BitSet) String ¶
String returns a string representation of the set. The elements are listed in ascending order.
Example: {0 2 4..7 9 11 13 15}
func (BitSet) Visit ¶
Visit calls the do function for each element of s in numerical order. If do returns true, Visit returns immediately, skipping any remaining elements, and returns true. It is safe for do to add or delete elements e, e ≤ n. The behavior of Visit is undefined if do changes the set in any other way.