Documentation
¶
Index ¶
- type Map
- func (s *Map[K, T]) BlockingSet(fn func(val map[K]T) map[K]T)
- func (s *Map[K, T]) BlockingSetKey(key K, fn func(val T) T)
- func (s *Map[K, T]) Copy() map[K]T
- func (s *Map[K, T]) DeleteKey(key K)
- func (s *Map[K, T]) Get() map[K]T
- func (s *Map[K, T]) GetKey(key K) (T, bool)
- func (s *Map[K, T]) Set(val map[K]T)
- func (s *Map[K, T]) SetKey(key K, val T)
- type RWSync
- type Slice
- func (s *Slice[T]) Clear()
- func (s *Slice[T]) Copy() []T
- func (s *Slice[T]) Get() []T
- func (s *Slice[T]) GetIndex(index int) T
- func (s *Slice[T]) Push(val T)
- func (s *Slice[T]) Set(val []T)
- func (s *Slice[T]) SetIndex(index int, value T)
- func (s *Slice[T]) Size() int
- func (s *Slice[T]) Splice(start int, length int) []T
- type Sync
- type Wrapped
- type WrappedMap
- type WrappedSlice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[K comparable, T any] Sync[map[K]T]
Map is a map wrapped in a mutex for safe concurrent use
func NewMap ¶
func NewMap[K comparable, T any]() *Map[K, T]
NewMap creates a new Sync object with an empty map
func (*Map[K, T]) BlockingSet ¶ added in v0.3.3
func (s *Map[K, T]) BlockingSet(fn func(val map[K]T) map[K]T)
func (*Map[K, T]) BlockingSetKey ¶ added in v0.3.4
func (s *Map[K, T]) BlockingSetKey(key K, fn func(val T) T)
func (*Map[K, T]) Copy ¶
func (s *Map[K, T]) Copy() map[K]T
Copy returns a shallow copy of the wrapped map
func (*Map[K, T]) DeleteKey ¶
func (s *Map[K, T]) DeleteKey(key K)
DeleteKey removes a key from the wrapped map
func (*Map[K, T]) Get ¶
func (s *Map[K, T]) Get() map[K]T
Get is a wrapper to SyncMap.Copy for compatibility with Wrapped
type RWSync ¶
type RWSync[T any] struct { // contains filtered or unexported fields }
RWSync wraps any value in a RWMutex for safe concurrent use. Unlike Sync, concurrent read access is allowed (so don't use it for things like maps and pointers!)
func (*RWSync[T]) BlockingSet ¶ added in v0.3.4
func (s *RWSync[T]) BlockingSet(fn func(val T) T)
BlockingSet locks the value temporarily until a function has modified it
type Slice ¶
Slice is a lice wrapped in a mutex for safe concurrent use
func (*Slice[T]) Copy ¶
func (s *Slice[T]) Copy() []T
Copy returns a shallow copy of the wrapped slice
func (*Slice[T]) Get ¶
func (s *Slice[T]) Get() []T
Get is a wrapper to SyncSlice.Copy for compatibility with Wrapped
type Sync ¶
type Sync[T any] struct { // contains filtered or unexported fields }
Sync wraps any value in a mutex for safe concurrent use
func (*Sync[T]) BlockingSet ¶ added in v0.3.4
func (s *Sync[T]) BlockingSet(fn func(val T) T)
BlockingSet locks the value temporarily until a function has modified it
type WrappedMap ¶
type WrappedMap[K comparable, V any] interface { Wrapped[map[K]V] GetKey(K) (V, bool) SetKey(K, V) }