hashset

package
v0.0.0-...-8cfa9df Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

A hash set can store unique values, without any particular order.

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 (s *Set[T]) Add(items ...T)

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

func (*Set[T]) Clear

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

Clear clears all values in the dsgo.

func (*Set[T]) Contains

func (s *Set[T]) Contains(items ...T) bool

Contains check if items (one or more) are present in the dsgo. 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 dsgo.

func (*Set[T]) Difference

func (s *Set[T]) Difference(another *Set[T]) *Set[T]

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[T]) Empty

func (s *Set[T]) Empty() bool

Empty returns true if set does not contain any elements.

func (*Set[T]) Intersection

func (s *Set[T]) Intersection(another *Set[T]) *Set[T]

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[T]) Len

func (s *Set[T]) Len() int

Len returns number of elements within the dsgo.

func (*Set[T]) Remove

func (s *Set[T]) Remove(items ...T)

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

func (*Set[T]) Union

func (s *Set[T]) Union(another *Set[T]) *Set[T]

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[T]) Values

func (s *Set[T]) Values() []T

Values returns all items in the dsgo.

Jump to

Keyboard shortcuts

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