hset

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Overview

Package hset implements a hset backed by a hash table.

Structure is thread safe.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hset

type Hset struct {

	// items sync.Map[interface{}]struct{}
	sync.RWMutex
	// contains filtered or unexported fields
}

Hset holds elements in go's native map

func New

func New() *Hset

New instantiates a new empty hset

func (*Hset) Add

func (hset *Hset) Add(items ...interface{})

Add adds the items (one or more) to the hset.

func (*Hset) Clear

func (hset *Hset) Clear()

Clear clears all values in the hset.

func (*Hset) Contains

func (hset *Hset) Contains(items ...interface{}) bool

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

func (*Hset) Empty

func (hset *Hset) Empty() bool

Empty returns true if hset does not contain any elements.

func (*Hset) Exists

func (hset *Hset) Exists(item interface{}) bool

Exists returns a bool indicating if the given item exists in the set.

func (*Hset) FromJSON

func (set *Hset) FromJSON(data []byte) error

FromJSON populates list's elements from the input JSON representation.

func (*Hset) Len

func (hset *Hset) Len() int

Len returns number of elements within the hset.

func (*Hset) Remove

func (hset *Hset) Remove(items ...interface{})

Remove removes the items (one or more) from the hset.

func (*Hset) Same

func (hset *Hset) Same(other Set) bool

Same to determine whether the two hset type values are the same.

func (*Hset) String

func (hset *Hset) String(pre ...bool) string

String returns a string representation of container

func (*Hset) ToJSON

func (set *Hset) ToJSON() ([]byte, error)

ToJSON outputs the JSON representation of list's elements.

func (*Hset) Values

func (hset *Hset) Values() []interface{}

Values returns all items in the hset. List()

type Set

type Set interface {
	Add(items ...interface{})
	Remove(items ...interface{})
	Clear()
	Contains(items ...interface{}) bool
	Len() int
	Same(other Set) bool
	Values() []interface{}
	String() string
}

Set hset interface

Jump to

Keyboard shortcuts

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