Documentation
¶
Overview ¶
Package syncmap provides a very small, generic wrapper around Go’s built-in map type guarded by a sync.RWMutex.
It trades a little indirection for convenience when a concurrent, goroutine safe map is needed but the full feature set (and memory cost) of `sync.Map` is not justified.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
func NewMap ¶
func NewMap[K comparable, V any]() *Map[K, V]
type OrderedMap ¶
type OrderedMap[T any] struct { *Map[string, T] // Holds a collection of prompts indexed by their names Keys []string }
OrderedMap is a generic collection type that holds items of type T indexed by string names
func NewOrderedMap ¶
func NewOrderedMap[T any]() *OrderedMap[T]
func (*OrderedMap[T]) Add ¶
func (c *OrderedMap[T]) Add(key string, item T) bool
Add adds a new item to the collection, if the name already exists it will overwrite the existing item
func (*OrderedMap[T]) Get ¶
func (c *OrderedMap[T]) Get(name string) (T, bool)
Get retrieves an item from the collection by its name.
Click to show internal directories.
Click to hide internal directories.