set

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serialize

func Serialize[T comparable](set *HashSet[T]) ([]byte, error)

Serialize serializes a HashSet into bytes using cbor

Types

type HashSet

type HashSet[T comparable] struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

HashSet represents a simple thread safe hash set

func Deserialize

func Deserialize[T comparable](data []byte) (*HashSet[T], error)

Deserialize deserializes cbor data into a HashSet

func Diff

func Diff[T comparable](first, second *HashSet[T]) *HashSet[T]

Diff returns a set containing every element from two hash sets that does not exist in both

func NewHashSet

func NewHashSet[T comparable]() *HashSet[T]

NewHashSet creates a new thread safe hash set

func (*HashSet[T]) Add

func (set *HashSet[T]) Add(value T)

Add adds a value to the set

func (*HashSet[T]) Contains

func (set *HashSet[T]) Contains(value T) bool

Contains checks if a specific value is present in the set

func (*HashSet[T]) Size

func (set *HashSet[T]) Size() int

Size returns the amount of elements stored inside the set

func (*HashSet[T]) ToSlice

func (set *HashSet[T]) ToSlice() []T

ToSlice returns a slice containing every element of the set

Jump to

Keyboard shortcuts

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