Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToSortedSlice ¶
func ToSortedSlice[E constraints.Ordered](s OrderedSet[E]) (list []E)
Types ¶
type ComparableSet ¶
type ComparableSet[E comparable] interface { Set[E] }
type HashSet ¶
type HashSet[E comparable] struct { // contains filtered or unexported fields }
Example ¶
set1 := NewHashSet("e", "c", "b", "b", "c")
fmt.Println(ToSortedSlice[string](set1)) // [b c e]
set1.Add("t")
set1.Add("a")
fmt.Println(ToSortedSlice[string](set1)) // [a b c e t]
fmt.Println(set1.Contains("b")) // true
set1.Remove("b")
fmt.Println(ToSortedSlice[string](set1)) // [a c e t]
fmt.Println(set1.Contains("b")) // false
fmt.Println(set1.Size()) // 4
set1.Clear()
fmt.Println(set1.Size()) // 0
Output: [b c e] [a b c e t] true [a c e t] false 4 0
func NewHashSet ¶
func NewHashSet[E comparable](elements ...E) (hashSet *HashSet[E])
type OrderedSet ¶
type OrderedSet[E constraints.Ordered] interface { Set[E] }
type Set ¶
type Set[E any] interface { collection.Collection[E] }
type X ¶
type X[E any] struct { collection.X[E] }
func Xof ¶
func Xof[E any](base collection.Collection[E]) X[E]
Click to show internal directories.
Click to hide internal directories.