indexset

package
v0.0.0-...-2c21e3b Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package indexset implements a set for indices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set map[uint32]struct{}

Set is the base type implemented by this package.

func New

func New(sizeHint int) Set

New returns a new empty set, with capacity sizeHint.

func NewFromSlice

func NewFromSlice(values ...uint32) Set

NewFromSlice returns a new set, initialized with the unique values in the given slice.

func (Set) Add

func (s Set) Add(value uint32) bool

Add ensures this set contains the given value. Returns true if it was added, and false if it already contained the value.

func (Set) AddAll

func (s Set) AddAll(values []uint32)

AddAll ensures this set contains all the values in the given slice.

func (Set) Contains

func (s Set) Contains(other Set) bool

Contains returns true if this set contains all elements from the other set.

func (Set) Difference

func (s Set) Difference(other Set) Set

Difference returns a new set which is this set with all elements from the other set removed (i.e. `self - other`).

func (Set) Has

func (s Set) Has(value uint32) bool

Has returns whether this set contains the given value.

func (Set) HasAll

func (s Set) HasAll(values ...uint32) bool

HasAll returns whether this set contains all the values in the given slice.

func (Set) Intersect

func (s Set) Intersect(other Set) Set

Intersect returns a new set which is the intersection of this set with the other set.

func (Set) Len

func (s Set) Len() int

Len returns the number of elements in this set.

func (Set) Remove

func (s Set) Remove(value uint32) bool

Remove ensures this set does not contain the value. Returns true if the value was deleted, and false if the value was already not in the set.

func (Set) RemoveAll

func (s Set) RemoveAll(values []uint32)

RemoveAll ensures this set does not contain any of the values in the given slice.

func (Set) ToSlice

func (s Set) ToSlice() []uint32

ToSlice renders this set to a slice of all values contained in the set.

func (Set) ToSortedSlice

func (s Set) ToSortedSlice() []uint32

ToSortedSlice renders this set to a sorted slice of all values contained in the set.

func (Set) Union

func (s Set) Union(other Set) Set

Union returns a new set which contains all element from this set, as well as all elements from the other set.

Jump to

Keyboard shortcuts

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