Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clonable ¶
type Clonable[T any] interface { Clone() T }
Clonable defines a constraint of types having Clone() T method.
type Entry ¶
type Entry[K comparable, V any] struct { Key K Value V }
Entry defines a key/value pairs.
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
Set represents a thread-safe set data structure that stores unique elements of type T. Backed by a regular map protected by sync.RWMutex, which is more efficient than sync.Map for most set workloads (frequent reads and writes on the same keys).
func NewSet ¶
func NewSet[T comparable]() *Set[T]
NewSet creates a new instance of the Set data structure.
func (*Set[T]) Exist ¶
Exist checks if an element exists in the set. It returns a boolean indicating whether the element exists in the set (true if exists, false if not found).
func (*Set[T]) Pop ¶
Pop removes an element from the set. It returns the removed element and a boolean indicating whether the element existed in the set.
func (*Set[T]) Put ¶
Put adds an element to the set. It returns a boolean indicating whether the element was added successfully (true if added, false if already exists).
func (*Set[T]) Range ¶
Range iterates over all elements in the set and calls the provided function for each element. It stops iteration if the function returns false. Note: the callback is invoked under a read lock; avoid long-running or blocking operations inside it.