syncset

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterator

type Iterator[T any] struct {
	// contains filtered or unexported fields
}

Iterator is a wrapper around an iterator that provides thread-safe access to the underlying collection.

func (Iterator[T]) Get

func (it Iterator[T]) Get() T

Get returns the current element.

func (Iterator[T]) Move

func (it Iterator[T]) Move()

Move moves the iterator to the next element.

func (Iterator[T]) Remove

func (it Iterator[T]) Remove()

Remove removes the current element.

func (Iterator[T]) Valid

func (it Iterator[T]) Valid() bool

Valid returns true if the iterator is currently pointing to a valid element.

type Wrapper

type Wrapper[T any] struct {
	// contains filtered or unexported fields
}

Wrapper is a wrapper around a set that provides thread-safe access to the set. Locking is done through read-write mutex. This means that multiple goroutines can read from the set at the same time, but only one goroutine can write to the set at the same time.

func From

func From[T any](set sets.Set[T]) *Wrapper[T]

From creates a new Wrapper from the given set.

func (*Wrapper[T]) Add

func (w *Wrapper[T]) Add(value T)

Add adds the given value to the set.

func (*Wrapper[T]) Clear

func (w *Wrapper[T]) Clear()

Clear removes all elements from the set.

func (*Wrapper[T]) Clone

func (w *Wrapper[T]) Clone() sets.Set[T]

Clone returns a shallow copy of the set.

func (*Wrapper[T]) Contains

func (w *Wrapper[T]) Contains(value T) bool

Contains returns true if the set contains the given value.

func (*Wrapper[T]) Iterator

func (w *Wrapper[T]) Iterator() iter.Iterator[T]

Iterator returns an iter.Iterator over the elements in the set.

func (*Wrapper[T]) Remove

func (w *Wrapper[T]) Remove(value T)

Remove removes the given value from the set.

func (*Wrapper[T]) SetIterator

func (w *Wrapper[T]) SetIterator() sets.Iterator[T]

SetIterator returns an iterator over the elements in the set.

func (*Wrapper[T]) Size

func (w *Wrapper[T]) Size() int

Size returns the number of elements in the set.

func (*Wrapper[T]) Stream

func (w *Wrapper[T]) Stream(yield func(T) bool)

Stream streams the elements of the Set.

func (*Wrapper[T]) Transaction

func (w *Wrapper[T]) Transaction(updateFunction func(set sets.Set[T]))

Transaction executes the given update function with the set as an argument. The set is locked for writing during the execution of the update function.

Jump to

Keyboard shortcuts

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