type Map … type readOnly … var expunged … type entry … func newEntry(i any) *entry { … } func (m *Map) loadReadOnly() readOnly { … } // 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 (m *Map) Load(key any) (value any, ok bool) { … } func (e *entry) load() (value any, ok bool) { … } // Store sets the value for a key. func (m *Map) Store(key, value any) { … } // Clear deletes all the entries, resulting in an empty Map. func (m *Map) Clear() { … } // tryCompareAndSwap compare the entry with the given old value and swaps // it with a new value if the entry is equal to the old value, and the entry // has not been expunged. // // If the entry is expunged, tryCompareAndSwap returns false and leaves // the entry unchanged. func (e *entry) tryCompareAndSwap(old, new any) bool { … } // unexpungeLocked ensures that the entry is not marked as expunged. // // If the entry was previously expunged, it must be added to the dirty map // before m.mu is unlocked. func (e *entry) unexpungeLocked() (wasExpunged bool) { … } // swapLocked unconditionally swaps a value into the entry. // // The entry must be known not to be expunged. func (e *entry) swapLocked(i *any) *any { … } // 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. func (m *Map) LoadOrStore(key, value any) (actual any, loaded bool) { … } // tryLoadOrStore atomically loads or stores a value if the entry is not // expunged. // // If the entry is expunged, tryLoadOrStore leaves the entry unchanged and // returns with ok==false. func (e *entry) tryLoadOrStore(i any) (actual any, loaded, ok bool) { … } // LoadAndDelete deletes the value for a key, returning the previous value if any. // The loaded result reports whether the key was present. func (m *Map) LoadAndDelete(key any) (value any, loaded bool) { … } // Delete deletes the value for a key. func (m *Map) Delete(key any) { … } func (e *entry) delete() (value any, ok bool) { … } // trySwap swaps a value if the entry has not been expunged. // // If the entry is expunged, trySwap returns false and leaves the entry // unchanged. func (e *entry) trySwap(i *any) (*any, bool) { … } // Swap swaps the value for a key and returns the previous value if any. // The loaded result reports whether the key was present. func (m *Map) Swap(key, value any) (previous any, loaded bool) { … } // 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 (m *Map) CompareAndSwap(key, old, new any) (swapped bool) { … } // 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 (m *Map) CompareAndDelete(key, old any) (deleted bool) { … } // Range calls f sequentially for each key and value present in the map. // If f returns false, range stops the iteration. // // Range 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 (including by f), Range may reflect any // mapping for that key from any point during the Range call. Range does not // block other methods on the receiver; even f itself may call any method on m. // // Range may be O(N) with the number of elements in the map even if f returns // false after a constant number of calls. func (m *Map) Range(f func(key, value any) bool) { … } func (m *Map) missLocked() { … } func (m *Map) dirtyLocked() { … } func (e *entry) tryExpungeLocked() (isExpunged bool) { … }