set

package module
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: MIT Imports: 3 Imported by: 10

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 Create

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

Create creates a new set containing the optional values Deprecated: use New() instead.

func Difference added in v0.2.0

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

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

func Intersection added in v0.2.0

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

Intersection returns a new set containing the values that exist in both setA and setB

func New added in v0.3.0

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

New creates a new set containing the optional values

func Union added in v0.2.0

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

Union returns a new set containing the 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 added in v0.4.3

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

Clone returns a copy of the set

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

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

Contains returns true if the set contains value

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

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

Copy returns a copy of the set Deprecated: use Clone() instead.

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

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

Equals returns true if both sets contain the same values

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

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 added in v0.3.0

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

ListOrdered returns all values present in the set, in order

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

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