set

package
v0.0.0-...-5a5e209 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2025 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] interface {
	// Add adds the specified element to this set if it is not already present.
	// Returns true if the element was added (i.e., it was not already in the set).
	Add(element T) bool

	// Remove removes the specified element from this set if it is present.
	// Returns true if the element was removed (i.e., it was in the set).
	Remove(element T) bool

	// Contains checks whether this set contains the specified element.
	Contains(element T) bool

	// Len returns the number of elements in this set.
	Len() int

	// Clear removes all elements from this set.
	Clear()

	// Slice returns a new slice containing all elements of the set.
	Slice() []T
}

Set is a generic set interface for comparable elements.

func NewSafe

func NewSafe[T comparable]() Set[T]

NewSafe creates a new thread-safe set.

func NewUnsafe

func NewUnsafe[T comparable]() Set[T]

Jump to

Keyboard shortcuts

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