sets

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IntSet

type IntSet map[int]struct{}

func NewIntSet

func NewIntSet(items ...int) IntSet

NewIntSet creates a new Set with the given items.

func NewIntSetWithLength

func NewIntSetWithLength(l int) IntSet

NewIntSetWithLength returns an empty Set with the given capacity. It's only a hint, not a limitation.

func (IntSet) Contains

func (s IntSet) Contains(item int) bool

Contains returns whether the given item is in the set.

func (IntSet) Insert

func (s IntSet) Insert(item int) IntSet

Insert a single item to this Set.

func (IntSet) InsertAll

func (s IntSet) InsertAll(items ...int) IntSet

InsertAll adds the items to this Set.

type Set

type Set map[string]struct{}

func New

func New(items ...string) Set

New creates a new Set with the given items.

func NewWithLength

func NewWithLength(l int) Set

NewWithLength returns an empty Set with the given capacity. It's only a hint, not a limitation.

func (Set) Contains

func (s Set) Contains(item string) bool

Contains returns whether the given item is in the set.

func (Set) Copy

func (s Set) Copy() Set

Copy this set.

func (Set) Delete

func (s Set) Delete(item string) Set

Delete removes an item from the set.

func (Set) DeleteAll

func (s Set) DeleteAll(items ...string) Set

Delete removes items from the set.

func (Set) Difference

func (s Set) Difference(s2 Set) Set

Difference returns a set of objects that are not in s2 For example: s = {a1, a2, a3} s2 = {a1, a2, a4, a5} s.Difference(s2) = {a3} s2.Difference(s) = {a4, a5}

func (Set) Equals

func (s Set) Equals(other Set) bool

Equals checks whether the given set is equal to the current set.

func (Set) Insert

func (s Set) Insert(item string) Set

Insert a single item to this Set.

func (Set) InsertAll

func (s Set) InsertAll(items ...string) Set

InsertAll adds the items to this Set.

func (Set) Intersection

func (s Set) Intersection(s2 Set) Set

Intersection returns a set of objects that are common between s and s2 For example: s = {a1, a2, a3} s2 = {a1, a2, a4, a5} s.Intersection(s2) = {a1, a2}

func (Set) IsEmpty

func (s Set) IsEmpty() bool

IsEmpty indicates whether the set is the empty set.

func (Set) Len

func (s Set) Len() int

Len returns the number of elements in this Set.

func (Set) Merge

func (s Set) Merge(s2 Set) Set

Merge a set of objects that are in s2 into s For example: s = {a1, a2, a3} s2 = {a3, a4, a5} s.Merge(s2) = {a1, a2, a3, a4, a5}

func (Set) SortedList

func (s Set) SortedList() []string

SortedList returns the slice with contents sorted.

func (Set) SupersetOf

func (s Set) SupersetOf(s2 Set) bool

SupersetOf returns true if s contains all elements of s2 For example: s = {a1, a2, a3} s2 = {a1, a2, a3, a4, a5} s.SupersetOf(s2) = false s2.SupersetOf(s) = true

func (Set) Union

func (s Set) Union(s2 Set) Set

Union returns a set of objects that are in s or s2 For example: s = {a1, a2, a3} s2 = {a1, a2, a4, a5} s.Union(s2) = s2.Union(s) = {a1, a2, a3, a4, a5}

func (Set) UnsortedList

func (s Set) UnsortedList() []string

UnsortedList returns the slice with contents in random order.

Jump to

Keyboard shortcuts

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