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