set

package
v0.0.0-...-9472f59 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2025 License: EUPL-1.2 Imports: 3 Imported by: 2

Documentation

Overview

Package set provides a simple set type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

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

Set is an unordered collection of non-duplicate elements.

func New

func New[E comparable](elems ...E) *Set[E]

New creates a new set with the given elements.

func (*Set[E]) Add

func (s *Set[E]) Add(elem E) *Set[E]

Add an elements to the set.

func (*Set[E]) Clone

func (s *Set[E]) Clone() *Set[E]

Clone returns a full copy of the set.

func (*Set[E]) Contains

func (s *Set[E]) Contains(elem E) bool

Contains returns true, if the set contains the element.

func (*Set[E]) Equal

func (s *Set[E]) Equal(other *Set[E]) bool

Equal returns true if both sets contain the same elements.

func (*Set[E]) Length

func (s *Set[E]) Length() int

Length returns the number of elements in the set.

func (*Set[E]) Remove

func (s *Set[E]) Remove(elem E) *Set[E]

Remove an element from the set.

func (*Set[E]) String

func (s *Set[E]) String() string

String returns a string representation.

func (*Set[E]) Values

func (s *Set[E]) Values() iter.Seq[E]

Values returns an iterator of all elements of the set.

Jump to

Keyboard shortcuts

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