sets

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyStruct = struct{}{}

EmptyStruct zero memory

Functions

This section is empty.

Types

type HashSet

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

HashSet holds elements in go's native map

func (*HashSet[T]) Add

func (set *HashSet[T]) Add(elements ...T)

func (*HashSet[T]) Clear

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

func (*HashSet[T]) Contains

func (set *HashSet[T]) Contains(elements ...T) bool

Contains check if items (one or more) are present in the set. All items have to be present in the set for the method to return true. Returns true if no arguments are passed at all, i.e. set is always superset of empty set.

func (*HashSet[T]) FromJSON

func (set *HashSet[T]) FromJSON(data []byte) error

FromJSON populates the set from the input JSON representation.

func (*HashSet[T]) IsEmpty

func (set *HashSet[T]) IsEmpty() bool

IsEmpty returns true if set does not contain any elements.

func (*HashSet[T]) MarshalJSON

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

MarshalJSON @implements json.Marshaler

func (*HashSet[T]) Remove

func (set *HashSet[T]) Remove(elements ...T)

func (*HashSet[T]) Size

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

func (*HashSet[T]) String

func (set *HashSet[T]) String() string

func (*HashSet[T]) ToJSON

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

ToJSON outputs the JSON representation of the set.

func (*HashSet[T]) UnmarshalJSON

func (set *HashSet[T]) UnmarshalJSON(bytes []byte) error

UnmarshalJSON @implements json.Unmarshaler

func (*HashSet[T]) Values

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

type ISet

type ISet[T any] interface {
	Add(elements ...T)
	Remove(elements ...T)
	Contains(elements ...T) bool
	IsEmpty() bool
	Size() int
	Clear()
	Values() []T
	String() string
}

ISet interface that all sets implement

func NewHashSet

func NewHashSet[T comparable]() ISet[T]

Jump to

Keyboard shortcuts

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