set

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2025 License: MIT Imports: 3 Imported by: 5

README

set

Test GoDoc

Basic set implemented with generics.

Authors

  • Christophe Lambin

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set[T cmp.Ordered] map[T]struct{}

Set holds a set of unique values

func Difference

func Difference[T cmp.Ordered](setA, setB Set[T]) Set[T]

Difference returns a new set containing the values from setA that don't exist in setB

func Intersection

func Intersection[T cmp.Ordered](setA, setB Set[T]) Set[T]

Intersection returns a new set containing the common values between setA and setB

func New

func New[T cmp.Ordered](values ...T) Set[T]

New creates a new set containing the optional values

func Union

func Union[T cmp.Ordered](setA, setB Set[T]) Set[T]

Union returns a new set containing all values from setA and setB

func (Set[T]) Add

func (s Set[T]) Add(value ...T)

Add adds value to the set

func (Set[T]) Clone

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

Clone returns a copy of the set

func (Set[T]) Contains

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

Contains returns true if the set contains value

func (Set[T]) Equals

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

Equals returns true if both sets contain the same values

func (Set[T]) List

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

List returns all values present in the set. Order is not guaranteed. If ListOrdered() if required.

func (Set[T]) ListOrdered

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

ListOrdered returns all values present in the set, in order

func (Set[T]) Remove

func (s Set[T]) Remove(value ...T)

Remove deletes value from the set, if present

Jump to

Keyboard shortcuts

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