Documentation
¶
Index ¶
- type Graph
- type Queue
- type Set
- func (s Set[V]) Add(v V)
- func (s Set[V]) Difference(other Set[V]) Set[V]
- func (s Set[V]) Equal(other Set[V]) bool
- func (s Set[V]) Has(v V) bool
- func (s Set[V]) Intersect(other Set[V]) Set[V]
- func (s Set[V]) Len() int
- func (s Set[V]) List() []V
- func (s Set[V]) Remove(v V)
- func (s Set[V]) SymmetricDifference(other Set[V]) Set[V]
- func (s Set[V]) Union(other Set[V]) Set[V]
- type Stack
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Graph ¶ added in v0.0.2
type Graph[K comparable] map[K][]K
func NewGraph ¶ added in v0.0.2
func NewGraph[K comparable]() Graph[K]
type Set ¶ added in v0.0.3
type Set[V comparable] map[V]bool
func Intersect ¶ added in v0.0.4
func Intersect[V comparable](sets ...Set[V]) Set[V]
func NewSet ¶ added in v0.0.3
func NewSet[V comparable]() Set[V]
NewSet constructor to create new set Example: NewSet(int)() to create a int set NewSet(string)() to create a string set
func ToSet ¶ added in v0.0.3
func ToSet[V comparable](vals []V) Set[V]
ToSet method initializes new Set from slice Example: input := []string{"a", "b", "c"} newSet := ToSet[string](input)
func Union ¶ added in v0.0.4
func Union[V comparable](sets ...Set[V]) Set[V]
func (Set[V]) Difference ¶ added in v0.0.4
Difference returns a set of objects that are not in s2 For example: s1 = {a1, a2, a3} s2 = {a1, a2, a4, a5} s1.Difference(s2) = {a3} s2.Difference(s1) = {a4, a5}
func (Set[V]) Equal ¶ added in v0.0.3
Equal returns true if and only if original is equal (as a set) to other. Two sets are equal if their membership is identical. (In practice, this means same elements, order doesn't matter)
func (Set[V]) Intersect ¶ added in v0.0.4
Intersect returns a new set which includes the item in BOTH s1 and s2 For example: s1 = {a1, a2} s2 = {a2, a3} s1.Intersect(s2) = {a2}
func (Set[V]) List ¶ added in v0.0.3
func (s Set[V]) List() []V
List returns the contents as a slice
func (Set[V]) SymmetricDifference ¶ added in v0.0.4
SymmetricDifference returns set of elements which are in either of the sets, but not in their intersection For example: s1 = {a1, a2, a3} s2 = {a3, a4} s1.SymmetricDifference(s2) = {a1, a2, a4}