set

package
v0.67.2 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2025 License: Apache-2.0 Imports: 3 Imported by: 19

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 {
	// Append adds multiple items to the set and returns the new size
	Append(val ...T) int

	// Remove removes an item from the set
	Remove(item T)

	// Contains checks if an item exists in the set
	Contains(item T) bool

	// Size returns the number of items in the set
	Size() int

	// Clear removes all items from the set
	Clear()

	// Clone returns a new set with a copy of all items
	Clone() Set[T]

	// Items returns all items in the set as a slice
	Items() []T

	// Iter returns an iterator over the set
	Iter() iter.Seq[T]

	// Union returns a new set containing all items from both sets
	Union(other Set[T]) Set[T]

	// Intersection returns a new set containing items present in both sets
	Intersection(other Set[T]) Set[T]

	// Difference returns a new set containing items present in this set but not in the other
	Difference(other Set[T]) Set[T]
}

Set defines the interface for set operations

func New

func New[T comparable](values ...T) Set[T]

New creates a new empty non-thread-safe set with optional initial values

Jump to

Keyboard shortcuts

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