Documentation
¶
Overview ¶
Package set implements the set data structure and the fundamental operations on sets.
Index ¶
- func Equal(setA, setB *Set) bool
- func Print(set *Set)
- type Pair
- type Set
- func (set *Set) Add(elem interface{})
- func (set *Set) Card() int
- func (set *Set) GetOne() (interface{}, error)
- func (set *Set) Has(elem interface{}) bool
- func (set *Set) IsEmpty() bool
- func (set *Set) IsSubsetOf(set2 *Set) bool
- func (set *Set) IsSupersetOf(set2 *Set) bool
- func (set *Set) Remove(elem interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Set ¶
type Set map[interface{}]struct{}
Set type models sets. The elements of a set are the keys of the underlying map. Since a set is a map, its elements (the keys of the map) must be comparable types, that is boolean, numeric, string, pointer, channel or interface types, or structs or arrays that contain only those types.
func New ¶
func New(elems ...interface{}) *Set
New creates a new set with the specified elements and returns a pointer to it.
func (*Set) GetOne ¶
GetOne returns a random element from a set and an error. If the set is empty it returns nil and the error "Set is empty".
func (*Set) IsSubsetOf ¶
IsSubsetOf checks if a set is a subset of the specified set.
func (*Set) IsSupersetOf ¶
IsSupersetOf checks if a set is a superset of the specified set.