set

package
v0.0.0-...-9354101 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2022 License: MIT Imports: 3 Imported by: 0

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])

func (*HashSet[E]) Add

func (hashSet *HashSet[E]) Add(e E)

func (*HashSet[E]) Clear

func (hashSet *HashSet[E]) Clear()

func (*HashSet[E]) Contains

func (hashSet *HashSet[E]) Contains(e E) bool

func (*HashSet[E]) Remove

func (hashSet *HashSet[E]) Remove(e E)

func (*HashSet[E]) Size

func (hashSet *HashSet[E]) Size() int

func (*HashSet[E]) ToSlice

func (hashSet *HashSet[E]) ToSlice() []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]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL