Documentation
¶
Overview ¶
Package hashablesets provides functionality for creating and manipulating set data structures with hashable elements.
Index ¶
- func Add[H godash.Hashable](s *HashableSet[H], element H)
- func AddAll[H godash.Hashable](s *HashableSet[H], es ...H)
- func Contains[H godash.Hashable](s HashableSet[H], e H) bool
- func FromSet[H godash.Hashable](s HashableSet[H]) (vs []H)
- func IsSubsetOf[H godash.Hashable](a, b HashableSet[H]) bool
- func IsSupersetOf[H godash.Hashable](a, b HashableSet[H]) bool
- func Remove[H godash.Hashable](s *HashableSet[H], e H)
- func RemoveAll[H godash.Hashable](s *HashableSet[H], elements ...H)
- type HashableSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
func Add[H godash.Hashable](s *HashableSet[H], element H)
Add adds a new element to the HashableSet. Modifies the set in place, does not return a new set.
func AddAll ¶
func AddAll[H godash.Hashable](s *HashableSet[H], es ...H)
AddAll adds a new element to the HashableSet. Modifies the set in place, does not return a new set.
func Contains ¶
func Contains[H godash.Hashable](s HashableSet[H], e H) bool
Contains returns true if the HashableSet contains the element.
func FromSet ¶
func FromSet[H godash.Hashable](s HashableSet[H]) (vs []H)
FromSet returns a slice from a HashableSet.
func IsSubsetOf ¶
func IsSubsetOf[H godash.Hashable](a, b HashableSet[H]) bool
IsSubsetOf checks if a is a subset of b. Returns true if a is a subset of b, false otherwise.
func IsSupersetOf ¶
func IsSupersetOf[H godash.Hashable](a, b HashableSet[H]) bool
IsSupersetOf checks if a is a superset of b. Returns true if a is a superset of b, false otherwise.
func Remove ¶
func Remove[H godash.Hashable](s *HashableSet[H], e H)
Remove removes an element from the HashableSet. Modifies the set in place, does not return a new set.
func RemoveAll ¶
func RemoveAll[H godash.Hashable](s *HashableSet[H], elements ...H)
RemoveAll removes all elements passed as arguments from the HashableSet. Modifies the set in place, does not return a new set.
Types ¶
type HashableSet ¶
HashableSet is a set of values. Just a wrapper around a map where the keys are the sets elements and the values are always true.
func Difference ¶
func Difference[H godash.Hashable](a HashableSet[H], b HashableSet[H]) (c HashableSet[H])
Difference returns a new HashableSet with the elements that are in the first set but not in the second. Returns a new set, does not modify the original sets.
func Intersection ¶
func Intersection[H godash.Hashable](a, b HashableSet[H]) (c HashableSet[H])
Intersection returns a new HashableSet with the elements that are in both sets. Returns a new sets, does not modify the original sets.
func ToSet ¶
func ToSet[H godash.Hashable](vs []H) (s HashableSet[H])
ToSet returns a HashableSet from a slice.
func Union ¶
func Union[H godash.Hashable](a, b HashableSet[H]) (c HashableSet[H])
Union returns a new HashableSet with the elements that are in either set. Returns a new set, does not modify the original set.