sets

package
v0.0.0-...-e36dbc7 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0, Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Copyright 2017 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package sets provides sets for storing collections of unique elements.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IntSet

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

IntSet stores a set of unique int elements.

func NewIntSet

func NewIntSet(elements ...int) *IntSet

NewIntSet creates an IntSet containing the supplied initial int elements.

func (*IntSet) Contains

func (s *IntSet) Contains(element int) bool

Contains returns true if element is in the IntSet.

func (*IntSet) Copy

func (s *IntSet) Copy() *IntSet

Copy returns a newly allocated copy of the supplied IntSet.

func (*IntSet) Delete

func (s *IntSet) Delete(elements ...int)

Delete zero or more int elements from the IntSet. Any elements not present in the IntSet are simply ignored.

func (*IntSet) Difference

func (s *IntSet) Difference(other *IntSet) *IntSet

Difference returns a new IntSet containing the elements in the receiver that are not present in the argument IntSet. Returns a copy of the receiver if the argument is nil.

func (*IntSet) Disjoint

func (s *IntSet) Disjoint(other *IntSet) bool

Disjoint returns true if the intersection of the receiver and the argument IntSets is the empty set. Returns true if the argument is nil or either IntSet is the empty set.

func (*IntSet) Elements

func (s *IntSet) Elements() []int

Elements returns a []int of the elements in the IntSet, in no particular (or consistent) order.

func (*IntSet) Empty

func (s *IntSet) Empty() bool

Empty returns true if the receiver is the empty set.

func (*IntSet) Equal

func (s *IntSet) Equal(other *IntSet) bool

Equal returns true if the receiver and the argument IntSet contain exactly the same elements. Returns false if the argument is nil.

func (*IntSet) Insert

func (s *IntSet) Insert(elements ...int)

Insert zero or more int elements into the IntSet. As expected for a Set, elements already present in the IntSet are simply ignored.

func (*IntSet) Intersect

func (s *IntSet) Intersect(other *IntSet) *IntSet

Intersect returns a new IntSet containing the intersection of the receiver and argument IntSets. Returns an empty set if the argument is nil.

func (*IntSet) Len

func (s *IntSet) Len() int

Len returns the number of unique elements in the IntSet.

func (*IntSet) Sorted

func (s *IntSet) Sorted() []int

Sorted returns a sorted []int of the elements in the IntSet.

func (*IntSet) String

func (s *IntSet) String() string

String formats the IntSet elements as sorted ints, representing them in "array initializer" syntax.

func (*IntSet) Union

func (s *IntSet) Union(other *IntSet) *IntSet

Union returns a new IntSet containing the union of the receiver and argument IntSets. Returns a copy of the receiver if the argument is nil.

func (*IntSet) Unique

func (s *IntSet) Unique(other *IntSet) *IntSet

Unique returns a new IntSet containing the elements in the receiver that are not present in the argument IntSet *and* the elements in the argument IntSet that are not in the receiver. Returns a copy of the receiver if the argument is nil.

Jump to

Keyboard shortcuts

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