hashset

package
Version: v1.18.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2022 License: BSD-2-Clause, ISC Imports: 5 Imported by: 231

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 struct {
	// contains filtered or unexported fields
}

Set holds elements in go's native map

func New

func New(values ...interface{}) *Set

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

func (*Set) Add

func (set *Set) Add(items ...interface{})

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

func (*Set) Clear

func (set *Set) Clear()

Clear clears all values in the set.

func (*Set) Contains

func (set *Set) Contains(items ...interface{}) 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) Difference added in v1.16.0

func (set *Set) Difference(another *Set) *Set

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

func (*Set) Empty

func (set *Set) Empty() bool

Empty returns true if set does not contain any elements.

func (*Set) FromJSON added in v1.9.0

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

FromJSON populates the set from the input JSON representation.

func (*Set) Intersection added in v1.16.0

func (set *Set) Intersection(another *Set) *Set

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

func (*Set) MarshalJSON added in v1.15.0

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

MarshalJSON @implements json.Marshaler

func (*Set) Remove

func (set *Set) Remove(items ...interface{})

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

func (*Set) Size

func (set *Set) Size() int

Size returns number of elements within the set.

func (*Set) String

func (set *Set) String() string

String returns a string representation of container

func (*Set) ToJSON added in v1.9.0

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

ToJSON outputs the JSON representation of the set.

func (*Set) Union added in v1.16.0

func (set *Set) Union(another *Set) *Set

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

func (*Set) UnmarshalJSON added in v1.15.0

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

UnmarshalJSON @implements json.Unmarshaler

func (*Set) Values

func (set *Set) Values() []interface{}

Values returns all items in the set.

Jump to

Keyboard shortcuts

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