Documentation
¶
Index ¶
- type Event
- type Map
- func (s *Map[K, T]) ChangeKey(key, new_key K) (T, bool)
- func (s *Map[K, T]) Clear()
- func (s *Map[K, T]) Clone() *Map[K, T]
- func (s *Map[K, T]) Delete(key K)
- func (s *Map[K, T]) DeleteIf(key K, condition func(T) bool)
- func (s *Map[K, T]) ForEach(fn func(key K, value T) bool)
- func (s *Map[K, T]) ForEachSnapshot(fn func(key K, value T) bool)
- func (s *Map[K, T]) Get(key K) (T, bool)
- func (s *Map[K, T]) GetOrSet(key K, valueFn func() T) (actual T, loaded bool)
- func (s *Map[K, T]) Iterator() iter.Seq2[K, T]
- func (s *Map[K, T]) Len() int
- func (s *Map[K, T]) Pop(key K) (T, bool)
- func (s *Map[K, T]) PopIf(key K, condition func(T) bool) (T, bool)
- func (s *Map[K, T]) Set(key K, value T)
- func (s *Map[K, T]) SnapshotIterator() iter.Seq2[K, T]
- func (s *Map[K, T]) UpdateIf(key K, condition func(T) bool, updateFn func(T) T) bool
- type Observable
- type Set
- func (s *Set[T]) Add(key T) bool
- func (s *Set[T]) Clear()
- func (s *Set[T]) Clone() *Set[T]
- func (s *Set[T]) Delete(key T)
- func (s *Set[T]) DeleteIf(key T, condition func(key T) bool)
- func (s *Set[T]) ForEach(fn func(key T) bool)
- func (s *Set[T]) ForEachSnapshot(fn func(key T) bool)
- func (s *Set[T]) Has(key T) bool
- func (s *Set[T]) Iterator() iter.Seq[T]
- func (s *Set[T]) Keys() []T
- func (s *Set[T]) Len() int
- func (s *Set[T]) Pop(key T) bool
- func (s *Set[T]) PopIf(key T, condition func(key T) bool) bool
- func (s *Set[T]) SnapshotIterator() iter.Seq[T]
- type Tuple
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event struct containing a state and a pointer to a channel
type Map ¶
type Map[K comparable, T any] struct { // contains filtered or unexported fields }
func NewMap ¶
func NewMap[K comparable, T any]() *Map[K, T]
func (*Map[K, T]) ForEachSnapshot ¶ added in v0.2.0
func (*Map[K, T]) SnapshotIterator ¶ added in v0.2.0
SnapshotIterator returns an iterator over an immutable copy (snapshot) of the map. This allows safe iteration without blocking concurrent access to the original map.
type Observable ¶
type Observable[T any] struct { // contains filtered or unexported fields }
Observable is a generic structure that represents a value that can be observed.
func NewObservable ¶
func NewObservable[T any](initialValue T) *Observable[T]
NewObservable creates a new Observable with an initial value.
func (*Observable[T]) Close ¶ added in v0.5.1
func (o *Observable[T]) Close()
Close terminates all subscriptions and cleans up the observable's resources.
func (*Observable[T]) Get ¶
func (o *Observable[T]) Get() T
Get returns the current value of the observable.
func (*Observable[T]) Len ¶
func (o *Observable[T]) Len() int
Len returns the number of observers currently subscribed.
func (*Observable[T]) Set ¶
func (o *Observable[T]) Set(value T)
Set updates the value of the observable and notifies all observers atomically.
func (*Observable[T]) Subscribe ¶
func (o *Observable[T]) Subscribe() (<-chan T, func())
Subscribe allows an observer to receive notifications. It returns a channel for receiving values and an unsubscribe function that must be called to clean up the subscription. The current value is sent to the subscriber upon subscription.
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
func NewSet ¶
func NewSet[T comparable]() *Set[T]
func (*Set[T]) Add ¶
Adds a key to the set. Returns `true` if the key was added, or `false` if it already existed.
func (*Set[T]) DeleteIf ¶ added in v0.5.1
DeleteIf deletes the given key from the set, but only if the key exists and satisfies the provided condition. The operation is atomic.
func (*Set[T]) ForEachSnapshot ¶ added in v0.2.0
func (*Set[T]) PopIf ¶ added in v0.5.1
PopIf removes a key from the set, but only if it exists and satisfies the condition. It returns true if the key was actually removed.
func (*Set[T]) SnapshotIterator ¶ added in v0.3.0
type Tuple ¶ added in v0.2.0
type Tuple[K comparable, T any] struct { // contains filtered or unexported fields }
Create a slice of key-value pairs