syncset

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2025 License: AGPL-3.0 Imports: 2 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 is a thread-safe set of items.

func New

func New[T comparable](items ...T) *Set[T]

NewSet creates a new set.

func (*Set[T]) Add

func (s *Set[T]) Add(item T) bool

Add adds an item to the set. Returns true if the item was added, false if it was already present.

func (*Set[T]) Contains

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

Contains returns true if the set contains the item.

func (*Set[T]) Items

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

Items returns a slice of all items in the set.

func (*Set[T]) Len

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

Len returns the number of items in the set.

func (*Set[T]) Range

func (s *Set[T]) Range(fn func(T))

Range calls the given function for each item in the set.

func (*Set[T]) Remove

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

Remove removes an item from the set.

Jump to

Keyboard shortcuts

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