goset

package module
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: BSD-2-Clause Imports: 5 Imported by: 0

README

goset

Golang module implementing set operations

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comparator

type Comparator[T comparable] func(a, b T) bool

A comparator returns true when a < b.

type Set

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

Set represents a (mathematical) set of values, supporting the set concepts of Union, Intersection, Difference

func New

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

New returns a new Set, optionally initialized with some members

func NewWithComparator

func NewWithComparator[T comparable](cmp Comparator[T], members ...T) Set[T]

NewWithComparator return a new Set and accepts a Comparator defining a sort function for members

func (Set[T]) Add

func (theSet Set[T]) Add(members ...T) Set[T]

Add adds a member to a Set, ignoring it if is already present

func (Set[T]) AsList

func (theSet Set[T]) AsList() []T

AsList returns a slice of values in theSet

func (Set[T]) AsSortedList

func (theSet Set[T]) AsSortedList() []T

AsSortedList returns a slice of values in theSet in a stable sorted order.

func (Set[T]) Clone

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

Clone returns a copy of this Set

func (Set[T]) Contains

func (theSet Set[T]) Contains(values ...T) bool

Contains returns a boolean indicating whether theSet contains all the given strs

func (Set[T]) Count

func (theSet Set[T]) Count() int

Count returns the set cardinality of theSet

func (Set[T]) Equals

func (theSet Set[T]) Equals(other Set[T]) bool

Equals returns a boolean indicating whether theSet is set-equal to other

func (Set[T]) Intersect

func (theSet Set[T]) Intersect(other Set[T]) Set[T]

Intersect returns a new Set resulting from the set intersection of theSet and other

func (Set[T]) IsProperSubsetOf

func (theSet Set[T]) IsProperSubsetOf(other Set[T]) bool

func (Set[T]) IsProperSupersetOf

func (theSet Set[T]) IsProperSupersetOf(other Set[T]) bool

func (Set[T]) IsSubsetOf

func (theSet Set[T]) IsSubsetOf(other Set[T]) bool

func (Set[T]) IsSupersetOf

func (theSet Set[T]) IsSupersetOf(other Set[T]) bool

func (Set[T]) Minus

func (theSet Set[T]) Minus(other Set[T]) Set[T]

Minus returns a new set representing the set difference theSet - other

func (Set[T]) String

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

String returns a string representation of theSet

func (Set[T]) Union

func (theSet Set[T]) Union(other Set[T]) Set[T]

Union returns a new Set resulting from the set union of theSet and other

Jump to

Keyboard shortcuts

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