datastructure

package
v0.0.0-...-e2a5574 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: LGPL-2.1 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set[T comparable] map[T]struct{}

Set uses map as set of items.

func NewSet

func NewSet[T comparable]() Set[T]

NewSet creates new set.

func NewSetFrom

func NewSetFrom[T comparable](items ...T) Set[T]

CreateSet creates new set with given values.

func (Set[T]) Add

func (this Set[T]) Add(item T)

Add adds item to the set.

func (Set[T]) AddMany

func (this Set[T]) AddMany(items ...T)

AddMany adds item to the set.

func (Set[T]) Contains

func (this Set[T]) Contains(item T) bool

Contains checks if item is in the set.

func (Set[T]) IsEmpty

func (this Set[T]) IsEmpty() bool

IsEmpty checks whether the set is empty or not.

func (Set[T]) Length

func (this Set[T]) Length() int

Length returns number of items in the set.

func (Set[T]) MarshalJSON

func (this Set[T]) MarshalJSON() ([]byte, error)

MarshalJSON belongs to json.Marshaler interface. It converts Golang object to JSON data.

func (Set[T]) Remove

func (this Set[T]) Remove(item T)

Remove removes item from the set. It does nothing if item does not exist in the set.

func (Set[T]) String

func (this Set[T]) String() string

String returns printable string of the set.

func (Set[T]) ToSlice

func (this Set[T]) ToSlice() []T

ToSlice converts the set to a slice.

func (*Set[T]) UnmarshalJSON

func (this *Set[T]) UnmarshalJSON(data []byte) error

UnmarshalJSON belongs to json.Unmarshaler interface. It parses JSON data to Golang object.

func (*Set[T]) UnmarshalText

func (this *Set[T]) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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