Documentation
¶
Index ¶
- type HashMap
- func (m *HashMap[K, V]) All() iter.Seq2[K, V]
- func (m *HashMap[K, V]) Clear()
- func (m *HashMap[K, V]) Delete(key K) (V, bool)
- func (m *HashMap[K, V]) Get(key K) (V, bool)
- func (m *HashMap[K, V]) Keys() iter.Seq[K]
- func (m *HashMap[K, V]) LoadOrStore(key K, newValue func() V) (actual V, loaded bool)
- func (m *HashMap[K, V]) Set(key K, value V) (prev V, changed bool)
- func (m *HashMap[K, V]) String() string
- func (m *HashMap[K, V]) Values() iter.Seq[V]
- type Map
- func (m *Map[K, V]) All() iter.Seq2[K, V]
- func (m *Map[K, V]) Clear()
- func (m *Map[K, V]) CompareAndDelete(key K, old V) (deleted bool)
- func (m *Map[K, V]) CompareAndSwap(key K, old, newVal V) (swapped bool)
- func (m *Map[K, V]) Delete(key K)
- func (m *Map[K, V]) Keys() iter.Seq[K]
- func (m *Map[K, V]) Load(key K) (V, bool)
- func (m *Map[K, V]) LoadAndDelete(key K) (V, bool)
- func (m *Map[K, V]) LoadOrStore(key K, value V) (V, bool)
- func (m *Map[K, V]) Store(key K, value V)
- func (m *Map[K, V]) Swap(key K, value V) (V, bool)
- func (m *Map[K, V]) Values() iter.Seq[V]
- type Queue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HashMap ¶
type HashMap[K, V any] struct { // contains filtered or unexported fields }
HashMap is a synchronized wrapper around hashmap.Map.
func NewHashMap ¶
func NewHashMap[K, V any](hasher internalmaphash.Hasher[K]) *HashMap[K, V]
NewHashMap returns a new map that uses the specified hash function and key-equivalence relation.
func (*HashMap[K, V]) All ¶
All returns an iterator over the key/value entries of the map in undefined order.
func (*HashMap[K, V]) Delete ¶
Delete removes the entry with the given key, if present. It reports whether the map changed, and returns the previous value, if any.
func (*HashMap[K, V]) Get ¶
Get reports whether the map contains the specified key, and returns the corresponding value if found, or the zero value if not.
func (*HashMap[K, V]) LoadOrStore ¶
LoadOrStore returns the existing value for key if present. Otherwise, it calls newValue to construct a value, stores it, and returns it. newValue is only called on a miss, so callers don't pay the cost of constructing a value when the key is already present. The loaded result is true if the value was loaded, false if stored. Unlike a separate Get followed by Set, this check-and-set is performed atomically under a single lock, so concurrent callers racing to initialize the same key never lose an update.
func (*HashMap[K, V]) Set ¶
Set updates the map entry for key to value and returns the previous entry, if any. It reports whether the map size increased.
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
func (*Map[K, V]) All ¶
All returns an iterator over the key-value pairs in the map. The iteration order is not specified and is not guaranteed to be the same from one iteration to the next.
All does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, All may reflect any mapping for that key from any point during the All call.
func (*Map[K, V]) Clear ¶
func (m *Map[K, V]) Clear()
Clear deletes all the entries, resulting in an empty Map.
func (*Map[K, V]) CompareAndDelete ¶
CompareAndDelete deletes the entry for key if its value is equal to old. The old value must be of a comparable type.
If there is no current value for key in the map, CompareAndDelete returns false (even if the old value is the nil interface value).
func (*Map[K, V]) CompareAndSwap ¶
CompareAndSwap swaps the old and new values for key if the value stored in the map is equal to old. The old value must be of a comparable type.
func (*Map[K, V]) Delete ¶
func (m *Map[K, V]) Delete(key K)
Delete deletes the value for a key. If the key is not in the map, Delete does nothing.
func (*Map[K, V]) Load ¶
Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.
func (*Map[K, V]) LoadAndDelete ¶
LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present.
func (*Map[K, V]) LoadOrStore ¶
LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.