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 ¶
- type IntSet
- func (s *IntSet) Contains(element int) bool
- func (s *IntSet) Copy() *IntSet
- func (s *IntSet) Delete(elements ...int)
- func (s *IntSet) Difference(other *IntSet) *IntSet
- func (s *IntSet) Disjoint(other *IntSet) bool
- func (s *IntSet) Elements() []int
- func (s *IntSet) Empty() bool
- func (s *IntSet) Equal(other *IntSet) bool
- func (s *IntSet) Insert(elements ...int)
- func (s *IntSet) Intersect(other *IntSet) *IntSet
- func (s *IntSet) Len() int
- func (s *IntSet) Sorted() []int
- func (s *IntSet) String() string
- func (s *IntSet) Union(other *IntSet) *IntSet
- func (s *IntSet) Unique(other *IntSet) *IntSet
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 (*IntSet) Delete ¶
Delete zero or more int elements from the IntSet. Any elements not present in the IntSet are simply ignored.
func (*IntSet) Difference ¶
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 ¶
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 ¶
Elements returns a []int of the elements in the IntSet, in no particular (or consistent) order.
func (*IntSet) Equal ¶
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 ¶
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 ¶
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) String ¶
String formats the IntSet elements as sorted ints, representing them in "array initializer" syntax.
func (*IntSet) Union ¶
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.