sets

package
v0.0.0-...-1cd82fe Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set[T comparable] map[T]struct{}

func Map

func Map[T, U comparable](set Set[T], mapper func(v T) U) Set[U]

Map converts all items in the set by using the mapper.

func New

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

New returns a new set that contains items.

func Product

func Product[T1, T2 comparable](s1 Set[T1], s2 Set[T2]) Set[tuples.Tuple2[T1, T2]]

Product returns a new set.

func (Set[T]) Add

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

Add adds items into the set.

func (Set[T]) Clone

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

Clone returns a new set that has same items with the set.

func (Set[T]) Contains

func (set Set[T]) Contains(item T) bool

Contains reports whether the set contains the item.

func (Set[T]) Difference

func (set Set[T]) Difference(other Set[T]) Set[T]

Difference returns a new set with items that are included by the set but not the other.

func (Set[T]) Equal

func (set Set[T]) Equal(other Set[T]) bool

Equal reports the other has same items.

func (Set[T]) Filter

func (set Set[T]) Filter(f func(v T) bool) Set[T]

Filter returns a new subset where f returns true for all items.

func (Set[T]) For

func (set Set[T]) For(f func(v T) error) error

For calls the f for each items in the set. If the f returns an error, For stops the iteration and return the error.

func (Set[T]) Intersection

func (set Set[T]) Intersection(other Set[T]) Set[T]

Intersection returns a new set with items that are included by both of the set and the other.

func (Set[T]) IsProperSubset

func (set Set[T]) IsProperSubset(other Set[T]) bool

IsProperSubset reports whether the set is a proper subset of the other.

func (Set[T]) IsProperSuperset

func (set Set[T]) IsProperSuperset(other Set[T]) bool

IsProperSuperset reports whether the set is a proper superset of the other.

func (Set[T]) IsSubset

func (set Set[T]) IsSubset(other Set[T]) bool

IsSubset reports whether the set is a subset of the other.

func (Set[T]) IsSuperset

func (set Set[T]) IsSuperset(other Set[T]) bool

IsSuperset reports whether the set is a superset of the other.

func (Set[T]) Len

func (set Set[T]) Len() int

Len returns the number of items in the set.

func (Set[T]) Remove

func (set Set[T]) Remove(items ...T) Set[T]

Remove removes items from the set.

func (Set[T]) SymmetricDifference

func (set Set[T]) SymmetricDifference(other Set[T]) Set[T]

SymmetricDifference returns a new set.

func (Set[T]) Union

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

Union returns a new set that with all items that are included by the set or the other.

Jump to

Keyboard shortcuts

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