Documentation
¶
Index ¶
- type ByteSet
- func Complement(set ByteSet) ByteSet
- func FromIter(bytes iter.Seq[byte]) (set ByteSet)
- func FromSeq(bytes seqs.Seq[byte]) ByteSet
- func FromValues(bytes ...byte) ByteSet
- func Intersection(sets ...ByteSet) (set ByteSet)
- func RelativeComplement(setA, setB ByteSet) (set ByteSet)
- func Union(sets ...ByteSet) (set ByteSet)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ByteSet ¶
type ByteSet struct {
// contains filtered or unexported fields
}
ByteSet is a set of bytes (8 bit values).
Internally, set membership is stored by a 256 bit bit array, each bit corresponding to a byte value. If a bit is set, the byte equal to its index is part of the set.
func Complement ¶
Complement returns the complement of the ByteSet.
func FromValues ¶
FromValues creates a ByteSet of the specified bytes.
Example:
s := ByteSetFromValues('a', '!', 42)
// s will now look like this:
// 63 42:'*' 33:'!' 0
// | | | |
// bits[0] 0000000000000000000001000000001000000000000000000000000000000000
// 127 97:'a' 64
// | | |
// bits[1] 0000000000000000000000000000001000000000000000000000000000000000
// 191 128
// | |
// bits[2] 0000000000000000000000000000000000000000000000000000000000000000
// 255 192
// | |
// bits[3] 0000000000000000000000000000000000000000000000000000000000000000
assert(s.Contains('*'))
assert(!s.Contains('A'))
assert(s.Len() == 3)
assert(slices.Collect(s.Values) == []byte{33, 42, 97})
func Intersection ¶
Intersection returns the intersection of the specified [ByteSet]s. NOTE: Returns a ByteSet matching every byte if sets is empty.
func RelativeComplement ¶
RelativeComplement returns the relative complement of set A in set B.
This is also known as the set difference of B and A, denoted B \ A or B - A.
func (ByteSet) ForEachUntil ¶
Click to show internal directories.
Click to hide internal directories.