hashset

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: BSD-2-Clause, ISC Imports: 6 Imported by: 0

Documentation

Overview

Package hashset implements a set backed by a hash table.

Structure is not thread safe.

References: http://en.wikipedia.org/wiki/Set_%28abstract_data_type%29

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

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

Set holds elements in go's native map

func New

func New[T comparable](values ...T) *Set[T]

New instantiates a new empty set and adds the passed values, if any, to the set

func (*Set[T]) Add

func (set *Set[T]) Add(items ...T)

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

func (*Set[T]) Clear

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

Clear clears all values in the set.

func (*Set[T]) Contains

func (set *Set[T]) Contains(items ...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 (*Set[T]) FromJSON

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

FromJSON populates the set from the input JSON representation.

func (*Set[T]) GetValues added in v0.3.0

func (set *Set[T]) GetValues() []T

Values returns all items in the set.

func (*Set[T]) IsEmpty added in v0.3.0

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

Empty returns true if set does not contain any elements.

func (*Set[T]) MakeDifferenceWith added in v0.3.0

func (set *Set[T]) MakeDifferenceWith(other sets.Set[T]) sets.Set[T]

Difference returns the difference between two sets. The new set consists of all elements that are in "set" but not in "other". Ref: https://proofwiki.org/wiki/Definition:Set_Difference

func (*Set[T]) MakeIntersectionWith added in v0.3.0

func (set *Set[T]) MakeIntersectionWith(other sets.Set[T]) sets.Set[T]

Intersection returns the intersection between two sets. The new set consists of all elements that are both in "set" and "other". Ref: https://en.wikipedia.org/wiki/Intersection_(set_theory)

func (*Set[T]) MakeUnionWith added in v0.3.0

func (set *Set[T]) MakeUnionWith(other sets.Set[T]) sets.Set[T]

Union returns the union of two sets. The new set consists of all elements that are in "set" or "other" (possibly both). Ref: https://en.wikipedia.org/wiki/Union_(set_theory)

func (*Set[T]) MarshalJSON

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

MarshalJSON @implements json.Marshaler

func (*Set[T]) Remove

func (set *Set[T]) Remove(_ utils.Comparator[T], items ...T)

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

func (*Set[T]) Size

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

Size returns number of elements within the set.

func (*Set[T]) ToJSON

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

ToJSON outputs the JSON representation of the set.

func (*Set[T]) ToString added in v0.3.0

func (set *Set[T]) ToString() string

String returns a string representation of container

func (*Set[T]) UnmarshalJSON

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

UnmarshalJSON @implements json.Unmarshaler

Jump to

Keyboard shortcuts

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