set

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 0 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] struct {
	// contains filtered or unexported fields
}

Set represents a collection of unique elements

func NewSet

func NewSet[T comparable]() *Set[T]

NewSet creates and initializes a new set

Returns:

  • a new set

func (*Set[T]) Add

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

Add inserts an element into the set

Parameters:

  • value: the element to insert

func (*Set[T]) Clear

func (s *Set[T]) Clear()

Clear removes all elements from the set

Parameters:

  • s: the set

func (*Set[T]) Contains

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

Contains checks if the set contains the specified element

Parameters:

  • value: the element to check

func (*Set[T]) Elements

func (s *Set[T]) Elements() []T

Elements returns a slice of all elements in the set

Returns:

  • a slice of all elements in the set

func (*Set[T]) Remove

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

Remove deletes an element from the set

Parameters:

  • value: the element to delete

func (*Set[T]) Size

func (s *Set[T]) Size() int

Size returns the number of elements in the set

Jump to

Keyboard shortcuts

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