Documentation
¶
Index ¶
- type Set
- func (s *Set) Add(x uint64)
- func (s *Set) AddMulti(a []uint64)
- func (s *Set) AppendTo(dst []uint64) []uint64
- func (s *Set) Clone() *Set
- func (s *Set) Del(x uint64)
- func (s *Set) Equal(a *Set) bool
- func (s *Set) ForEach(f func(part []uint64) bool)
- func (s *Set) Has(x uint64) bool
- func (s *Set) Intersect(a *Set)
- func (s *Set) Len() int
- func (s *Set) Marshal(dst []byte) []byte
- func (s *Set) SizeBytes() uint64
- func (s *Set) Subtract(a *Set)
- func (s *Set) Union(a *Set)
- func (s *Set) UnionMayOwn(a *Set)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set is a fast set for uint64.
It should work faster than map[uint64]struct{} for semi-sparse uint64 values such as MetricIDs generated by lib/storage.
It is unsafe calling Set methods from concurrent goroutines.
func Unmarshal ¶ added in v1.110.31
Unmarshal creates an instance of a set from bytes.
The first 8 src bytes contain the set length (number of the elements in the set). Since each element is 8-byte long, the number of remaining src bytes must be at least 8*length, or else the function will return an error. The function will read exactly 8*length bytes and construct an instance of a set. The remaining src bytes will be returned along with the set.
func (*Set) AddMulti ¶ added in v1.39.0
AddMulti adds all the items from a to s.
It is usually faster than calling s.Add() for each item in a.
The caller is responsible for splitting a into items with clustered values.
func (*Set) AppendTo ¶
AppendTo appends all the items from the set to dst and returns the result.
The returned items are sorted.
AppendTo can mutate s.
func (*Set) ForEach ¶ added in v1.32.3
ForEach calls f for all the items stored in s.
Each call to f contains part with arbitrary part of items stored in the set. The iteration is stopped if f returns false.
func (*Set) Marshal ¶ added in v1.110.31
Marshal encodes the set as a sequence of bytes.
The first 8 bytes contain the length of the set (number of the elements the set contains). The subsequent bytes are actual uint64 elements.
The marshaling result is appended to the end of dst, i.e. the initial dst content is not overwritten.
func (*Set) Subtract ¶ added in v1.29.0
Subtract removes from s all the shared items between s and a.
func (*Set) UnionMayOwn ¶ added in v1.32.6
UnionMayOwn adds all the items from a to s.
It may own a if s is empty. This means that `a` cannot be used after the call to UnionMayOwn.