set

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: BSD-3-Clause Imports: 2 Imported by: 0

README

set

A set type for Go.

Documentation: https://pkg.go.dev/github.com/andreas19/set

Documentation

Overview

Package set implements a Set type for Go.

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 type.

func New

func New[T comparable](elems ...T) Set[T]

New returns a new Set with the given elements.

func (Set[T]) Add

func (s Set[T]) Add(elem T) bool

Add adds elem to the Set. Returns true if it was added, false if it already was in the set.

func (Set[T]) Cardinality

func (s Set[T]) Cardinality() int

Cardinality returns the number of elements in the Set.

func (Set[T]) Clone

func (s Set[T]) Clone() Set[T]

Clone clones the Set.

func (Set[T]) Contains

func (s Set[T]) Contains(elem T) bool

Contains returns true if elem is in the Set.

func (Set[T]) Difference

func (s Set[T]) Difference(s2 Set[T]) Set[T]

Difference returns a new Set which is the set difference of s and s2.

func (Set[T]) Elements

func (s Set[T]) Elements() []T

Elements returns a slice with all elements of the Set.

func (Set[T]) Equal

func (s Set[T]) Equal(s2 Set[T]) bool

Equal returns true if s and s2 contain the same elements.

func (Set[T]) Intersection

func (s Set[T]) Intersection(s2 Set[T]) Set[T]

Intersection returns a new Set which is the intersection of s and s2.

func (Set[T]) IsEmpty

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

IsEmpty returns true if Set is an empty set.

func (Set[T]) IsProperSubset added in v0.2.0

func (s Set[T]) IsProperSubset(s2 Set[T]) bool

IsProperSubset returns true if s is a proper subset of s2.

func (Set[T]) IsSubset

func (s Set[T]) IsSubset(s2 Set[T]) bool

IsSubset returns true if s is a subset of s2.

func (Set[T]) Remove

func (s Set[T]) Remove(elem T) bool

Remove removes elem from the Set. Returns true if it was in the set, false otherwise.

func (Set[T]) String

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

String returns a string representation of the Set.

func (Set[T]) SymDifference added in v0.2.0

func (s Set[T]) SymDifference(s2 Set[T]) Set[T]

SymDifference returns a new Set which is the symmetric difference of s and s2.

func (Set[T]) Union

func (s Set[T]) Union(s2 Set[T]) Set[T]

Union returns a new Set which is the union of s and s2.

Jump to

Keyboard shortcuts

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