uint64set

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0, Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterator

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

Iterator is the iterator for Set

func (*Iterator) HasNext

func (itr *Iterator) HasNext() bool

func (*Iterator) Next

func (itr *Iterator) Next() uint64

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 (*Set) Add

func (s *Set) Add(x uint64)

Add adds x to s.

func (*Set) AddMulti

func (s *Set) AddMulti(a []uint64)

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

func (s *Set) AppendTo(dst []uint64) []uint64

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) Clone

func (s *Set) Clone() *Set

Clone returns an independent copy of s.

func (*Set) Del

func (s *Set) Del(x uint64)

Del deletes x from s.

func (*Set) Equal

func (s *Set) Equal(a *Set) bool

Equal returns true if s contains the same items as a.

func (*Set) ForEach

func (s *Set) ForEach(f func(part []uint64) bool)

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) Has

func (s *Set) Has(x uint64) bool

Has verifies whether x exists in s.

func (*Set) Intersect

func (s *Set) Intersect(a *Set)

Intersect removes all the items missing in a from s.

func (*Set) Iterator

func (s *Set) Iterator() *Iterator

func (*Set) Len

func (s *Set) Len() int

Len returns the number of distinct uint64 values in s.

func (*Set) SizeBytes

func (s *Set) SizeBytes() uint64

SizeBytes returns an estimate size of s in RAM.

func (*Set) Subtract

func (s *Set) Subtract(a *Set)

Subtract removes from s all the shared items between s and a.

func (*Set) Union

func (s *Set) Union(a *Set)

Union adds all the items from a to s.

func (*Set) UnionMayOwn

func (s *Set) UnionMayOwn(a *Set)

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.

Jump to

Keyboard shortcuts

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