Documentation ¶
Index ¶
- Constants
- type Map
- func (m *Map[K, V]) BulkSet(kvs map[K]V) error
- func (m *Map[K, V]) Clear()
- func (m *Map[K, V]) Clone() (*Map[K, V], error)
- func (m *Map[K, V]) Delete(k K) bool
- func (m *Map[K, V]) Get(k K) (V, bool)
- func (m *Map[K, V]) Keys() []K
- func (m *Map[K, V]) Len() int
- func (m *Map[K, V]) Map() map[K]V
- func (m *Map[K, V]) MarshalJSON() ([]byte, error)
- func (m *Map[K, V]) Range(f func(k K, v V) bool) bool
- func (m *Map[K, V]) Set(k K, v V) error
- func (m *Map[K, V]) UnmarshalJSON(b []byte) error
Constants ¶
View Source
const ( ErrBrokenRange = stringError("range was broken") ErrNilMap = stringError("map is nil") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[K constraints.Ordered, V any] struct { // contains filtered or unexported fields }
Map is a synchronized map.
func NewMap ¶
func NewMap[K constraints.Ordered, V any](m map[K]V) *Map[K, V]
NewMap returns a new Map from the given map. If the map is nil, a new map is created.
func (*Map[K, V]) Clone ¶ added in v1.1.0
Clone returns a new Map with a copy of the underlying map.
func (*Map[K, V]) Delete ¶
Delete removes the item for the given key. Returns true if an item was in the map and deleted.
func (*Map[K, V]) Get ¶
Get returns the value for the given key. Returns false if the key does not exist in the map.
func (*Map[K, V]) Keys ¶
func (m *Map[K, V]) Keys() []K
Keys returns a sorted slice of the keys in the map.
func (*Map[K, V]) MarshalJSON ¶ added in v1.5.1
func (*Map[K, V]) Range ¶
Range calls f sequentially for each key and value present in the map. Returning true from f will terminate the iteration.
func (*Map[K, V]) UnmarshalJSON ¶ added in v1.5.1
Click to show internal directories.
Click to hide internal directories.