Documentation ¶
Overview ¶
Package cmap provides a concurrent map.
Index ¶
- type DeleteFunc
- type Map
- func (m *Map[K, V]) Delete(key K, deleteFunc DeleteFunc[K, V]) bool
- func (m *Map[K, V]) Get(key K) (V, bool)
- func (m *Map[K, V]) Has(key K) bool
- func (m *Map[K, V]) Keys() []K
- func (m *Map[K, V]) Len() int
- func (m *Map[K, V]) Set(key K, value V)
- func (m *Map[K, V]) Upsert(key K, upsertFunc UpsertFunc[K, V]) V
- func (m *Map[K, V]) Values() []V
- type UpsertFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeleteFunc ¶
type DeleteFunc[K comparable, V any] func(value V, exists bool) bool
DeleteFunc is a function to delete a value from the map.
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
Map is a concurrent map that is safe for multiple routines. It is optimized to reduce lock contention and improve performance.
func (*Map[K, V]) Delete ¶
func (m *Map[K, V]) Delete(key K, deleteFunc DeleteFunc[K, V]) bool
Delete removes a value from the map.
func (*Map[K, V]) Upsert ¶
func (m *Map[K, V]) Upsert(key K, upsertFunc UpsertFunc[K, V]) V
Upsert inserts or updates a key-value pair.
type UpsertFunc ¶
type UpsertFunc[K comparable, V any] func(value V, exists bool) V
UpsertFunc is a function to insert or update a key-value pair.
Click to show internal directories.
Click to hide internal directories.