Documentation
¶
Index ¶
- func CloneMapIfNil[K comparable, V any, T any](dirty *T, original *T, getMap func(*T) map[K]V) map[K]V
- type Box
- func (b *Box[T]) Change(apply func(T))
- func (b *Box[T]) ChangeIf(cond func(T) bool, apply func(T)) bool
- func (b *Box[T]) Delete()
- func (b *Box[T]) Dirty() bool
- func (b *Box[T]) Finalize() (T, bool)
- func (b *Box[T]) Locked(fn func(Value[T]))
- func (b *Box[T]) Original() T
- func (b *Box[T]) Set(value T)
- func (b *Box[T]) Value() T
- type Cloneable
- type CloneableMap
- type FinalizationHooks
- type Map
- func (m *Map[K, V]) Add(key K, value V)
- func (m *Map[K, V]) Change(key K, apply func(V))
- func (m *Map[K, V]) Clear()
- func (m *Map[K, V]) Delete(key K)
- func (m *Map[K, V]) Finalize() (result map[K]V, changed bool)
- func (m *Map[K, V]) Get(key K) (*MapEntry[K, V], bool)
- func (m *Map[K, V]) Range(fn func(*MapEntry[K, V]) bool)
- func (m *Map[K, V]) TryDelete(key K) bool
- type MapBuilder
- type MapEntry
- func (e *MapEntry[K, V]) Change(apply func(V))
- func (e *MapEntry[K, V]) ChangeIf(cond func(V) bool, apply func(V)) bool
- func (e *MapEntry[K, V]) Delete()
- func (e *MapEntry) Dirty() bool
- func (e *MapEntry) Key() K
- func (e *MapEntry[K, V]) Locked(fn func(Value[V]))
- func (e *MapEntry) Original() V
- func (e *MapEntry[K, V]) Replace(newValue V)
- func (e *MapEntry) Value() V
- type SyncMap
- func (m *SyncMap[K, V]) Delete(key K)
- func (m *SyncMap[K, V]) Finalize() (map[K]V, bool)
- func (m *SyncMap[K, V]) FinalizeWith(hooks FinalizationHooks[K, V]) (map[K]V, bool)
- func (m *SyncMap[K, V]) Load(key K) (*SyncMapEntry[K, V], bool)
- func (m *SyncMap[K, V]) LoadOrStore(key K, value V) (*SyncMapEntry[K, V], bool)
- func (m *SyncMap[K, V]) Range(fn func(*SyncMapEntry[K, V]) bool)
- type SyncMapEntry
- func (e *SyncMapEntry[K, V]) Change(apply func(V))
- func (e *SyncMapEntry[K, V]) ChangeIf(cond func(V) bool, apply func(V)) bool
- func (e *SyncMapEntry[K, V]) Delete()
- func (e *SyncMapEntry[K, V]) DeleteIf(cond func(V) bool)
- func (e *SyncMapEntry[K, V]) Dirty() bool
- func (e *SyncMapEntry) Key() K
- func (e *SyncMapEntry[K, V]) Locked(fn func(Value[V]))
- func (e *SyncMapEntry) Original() V
- func (e *SyncMapEntry[K, V]) Value() V
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloneMapIfNil ¶
func CloneMapIfNil[K comparable, V any, T any](dirty *T, original *T, getMap func(*T) map[K]V) map[K]V
Types ¶
type CloneableMap ¶
type CloneableMap[K comparable, V any] map[K]V
func (CloneableMap[K, V]) Clone ¶
func (m CloneableMap[K, V]) Clone() CloneableMap[K, V]
type FinalizationHooks ¶
type FinalizationHooks[K comparable, V any] struct { OnDelete func(key K, value V) OnChange func(key K, oldValue V, newValue V) OnAdd func(key K, value V) }
type Map ¶
type Map[K comparable, V Cloneable[V]] struct { // contains filtered or unexported fields }
func NewMap ¶
func NewMap[K comparable, V Cloneable[V]](base map[K]V) *Map[K, V]
func (*Map[K, V]) Add ¶
func (m *Map[K, V]) Add(key K, value V)
Add sets a new entry in the dirty map without checking if it exists in the base map. The entry added is considered dirty, so it should be a fresh value, mutable until finalized (i.e., it will not be cloned before changing if a change is made). If modifying an entry that may exist in the base map, use `Change` instead.
type MapBuilder ¶
type MapBuilder[K comparable, VBase any, VBuilder any] struct { // contains filtered or unexported fields }
func NewMapBuilder ¶
func NewMapBuilder[K comparable, VBase any, VBuilder any]( base map[K]VBase, toBuilder func(VBase) VBuilder, build func(VBuilder) VBase, ) *MapBuilder[K, VBase, VBuilder]
func (*MapBuilder[K, VBase, VBuilder]) Build ¶
func (mb *MapBuilder[K, VBase, VBuilder]) Build() map[K]VBase
func (*MapBuilder[K, VBase, VBuilder]) Clear ¶
func (mb *MapBuilder[K, VBase, VBuilder]) Clear()
func (*MapBuilder[K, VBase, VBuilder]) Delete ¶
func (mb *MapBuilder[K, VBase, VBuilder]) Delete(key K)
func (*MapBuilder[K, VBase, VBuilder]) Has ¶
func (mb *MapBuilder[K, VBase, VBuilder]) Has(key K) bool
func (*MapBuilder[K, VBase, VBuilder]) Set ¶
func (mb *MapBuilder[K, VBase, VBuilder]) Set(key K, value VBuilder)
type MapEntry ¶
type MapEntry[K comparable, V Cloneable[V]] struct { // contains filtered or unexported fields }
type SyncMap ¶
type SyncMap[K comparable, V Cloneable[V]] struct { // contains filtered or unexported fields }
func NewSyncMap ¶
func NewSyncMap[K comparable, V Cloneable[V]](base map[K]V) *SyncMap[K, V]
func (*SyncMap[K, V]) FinalizeWith ¶
func (m *SyncMap[K, V]) FinalizeWith(hooks FinalizationHooks[K, V]) (map[K]V, bool)
func (*SyncMap[K, V]) Load ¶
func (m *SyncMap[K, V]) Load(key K) (*SyncMapEntry[K, V], bool)
func (*SyncMap[K, V]) LoadOrStore ¶
func (m *SyncMap[K, V]) LoadOrStore(key K, value V) (*SyncMapEntry[K, V], bool)
func (*SyncMap[K, V]) Range ¶
func (m *SyncMap[K, V]) Range(fn func(*SyncMapEntry[K, V]) bool)
type SyncMapEntry ¶
type SyncMapEntry[K comparable, V Cloneable[V]] struct { // contains filtered or unexported fields }
func (*SyncMapEntry[K, V]) Change ¶
func (e *SyncMapEntry[K, V]) Change(apply func(V))
func (*SyncMapEntry[K, V]) ChangeIf ¶
func (e *SyncMapEntry[K, V]) ChangeIf(cond func(V) bool, apply func(V)) bool
func (*SyncMapEntry[K, V]) Delete ¶
func (e *SyncMapEntry[K, V]) Delete()
func (*SyncMapEntry[K, V]) DeleteIf ¶
func (e *SyncMapEntry[K, V]) DeleteIf(cond func(V) bool)
func (*SyncMapEntry[K, V]) Dirty ¶
func (e *SyncMapEntry[K, V]) Dirty() bool
func (*SyncMapEntry[K, V]) Locked ¶
func (e *SyncMapEntry[K, V]) Locked(fn func(Value[V]))
func (*SyncMapEntry[K, V]) Value ¶
func (e *SyncMapEntry[K, V]) Value() V
Click to show internal directories.
Click to hide internal directories.