sets

package
v0.0.0-...-c1ed8fc Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package sets provides sets for storing collections of unique elements.

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StringSet

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

StringSet stores a set of unique string elements.

func NewStringSet

func NewStringSet(elements ...string) *StringSet

NewStringSet creates a StringSet containing the supplied initial string elements.

func (*StringSet) Contains

func (s *StringSet) Contains(element string) bool

Contains returns true if element is in the StringSet.

func (*StringSet) Copy

func (s *StringSet) Copy() *StringSet

Copy returns a newly allocated copy of the supplied StringSet.

func (*StringSet) Delete

func (s *StringSet) Delete(elements ...string)

Delete zero or more string elements from the StringSet. Any elements not present in the StringSet are simply ignored.

func (*StringSet) Difference

func (s *StringSet) Difference(other *StringSet) *StringSet

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

func (*StringSet) Disjoint

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

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

func (*StringSet) Elements

func (s *StringSet) Elements() []string

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

func (*StringSet) Empty

func (s *StringSet) Empty() bool

Empty returns true if the receiver is the empty set.

func (*StringSet) Equal

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

Equal returns true if the receiver and the argument StringSet contain exactly the same elements.

func (*StringSet) Insert

func (s *StringSet) Insert(elements ...string)

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

func (*StringSet) Intersect

func (s *StringSet) Intersect(other *StringSet) *StringSet

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

func (*StringSet) Len

func (s *StringSet) Len() int

Len returns the number of unique elements in the StringSet.

func (*StringSet) Sorted

func (s *StringSet) Sorted() []string

Sorted returns a sorted []string of the elements in the StringSet.

func (*StringSet) String

func (s *StringSet) String() string

String formats the StringSet elements as sorted strings, representing them in "array initializer" syntax.

func (*StringSet) Union

func (s *StringSet) Union(other *StringSet) *StringSet

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

func (*StringSet) Unique

func (s *StringSet) Unique(other *StringSet) *StringSet

Unique returns a new StringSet containing the elements in the receiver that are not present in the argument StringSet *and* the elements in the argument StringSet that are not in the receiver (which is the union of two disjoint sets). 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