### Get Length of SyncMap in Go Source: https://pkg.go.dev/github.com/playwright-community/playwright-go/internal/safe Returns the number of key-value pairs currently stored in the SyncMap. This provides the current size of the map. ```Go func (m *SyncMap[K, V]) Len() int ``` -------------------------------- ### Go SyncMap.Load Method Source: https://pkg.go.dev/github.com/playwright-community/playwright-go/@v0.5200.0/internal/safe Loads the value for a given key `k` from the SyncMap. It returns the value `v` and a boolean `ok` indicating whether the key was found. ```Go func (m *SyncMap[K, V]) Load(k K) (v V, ok bool) ``` -------------------------------- ### Go SyncMap.Clone Method Source: https://pkg.go.dev/github.com/playwright-community/playwright-go/@v0.5200.0/internal/safe Creates and returns a new standard Go map containing all key-value pairs currently present in the SyncMap. ```Go func (m *SyncMap[K, V]) Clone() map[K]V ``` -------------------------------- ### SyncMap Type and Methods (Go) Source: https://pkg.go.dev/github.com/playwright-community/playwright-go/@v0.5200.0/internal/safe API documentation for the `SyncMap` type, a thread-safe map implementation, including its constructor and various utility methods for concurrent key-value operations. ```APIDOC SyncMap: Description: A thread-safe map implementation. Definition: type SyncMap[K comparable, V any] struct { sync.RWMutex // contains filtered or unexported fields } Methods: NewSyncMap(): Description: Creates a new thread-safe map. Signature: func NewSyncMap[K comparable, V any]() *SyncMap[K, V] Clear(): Description: Clears all entries from the map. Signature: func (m *SyncMap[K, V]) Clear() Clone(): Description: Returns a copy of the map's contents as a standard Go map. Signature: func (m *SyncMap[K, V]) Clone() map[K]V Delete(k K): Description: Deletes the entry for a key. Parameters: k: The key to delete. Signature: func (m *SyncMap[K, V]) Delete(k K) Len(): Description: Returns the number of entries in the map. Signature: func (m *SyncMap[K, V]) Len() int Load(k K): Description: Loads the value for a key. Parameters: k: The key to load. Returns: v: The value associated with the key. ok: A boolean indicating if the key was found. Signature: func (m *SyncMap[K, V]) Load(k K) (v V, ok bool) LoadAndDelete(k K): Description: Loads and deletes the entry for a key. Parameters: k: The key to load and delete. Returns: v: The value associated with the key. loaded: A boolean indicating if the key was found. Signature: func (m *SyncMap[K, V]) LoadAndDelete(k K) (v V, loaded bool) LoadOrStore(k K, v V): Description: Loads an existing value for a key or stores a new one if not present. Parameters: k: The key to load or store. v: The value to store if the key is not present. Returns: actual: The value loaded or stored. loaded: A boolean indicating if the value was loaded (true) or stored (false). Signature: func (m *SyncMap[K, V]) LoadOrStore(k K, v V) (actual V, loaded bool) Range(f func(k K, v V) bool): Description: Iterates over the map's entries, calling a function for each. Parameters: f: A function to call for each key-value pair. If f returns false, Range stops. Signature: func (m *SyncMap[K, V]) Range(f func(k K, v V) bool) Store(k K, v V): Description: Stores a key-value pair in the map. Parameters: k: The key to store. v: The value to store. Signature: func (m *SyncMap[K, V]) Store(k K, v V) ``` -------------------------------- ### Clone SyncMap in Go Source: https://pkg.go.dev/github.com/playwright-community/playwright-go/internal/safe Creates and returns a new standard Go map containing all key-value pairs from the SyncMap at the time of cloning. This provides a snapshot of the map's contents. ```Go func (m *SyncMap[K, V]) Clone() map[K]V ``` -------------------------------- ### Go Type: SyncMap API Reference Source: https://pkg.go.dev/github.com/playwright-community/playwright-go/internal/safe Comprehensive API documentation for the `SyncMap` type, a generic thread-safe map in Go, detailing its structure and all available methods for concurrent data manipulation. ```APIDOC type SyncMap[K comparable, V any] struct { sync.RWMutex // contains filtered or unexported fields } Description: SyncMap is a thread-safe map Methods: Clear(): func (m *SyncMap[K, V]) Clear() Clone(): func (m *SyncMap[K, V]) Clone() map[K]V Delete(k K): func (m *SyncMap[K, V]) Delete(k K) Len(): func (m *SyncMap[K, V]) Len() int Load(k K): func (m *SyncMap[K, V]) Load(k K) (v V, ok bool) LoadAndDelete(k K): func (m *SyncMap[K, V]) LoadAndDelete(k K) (v V, loaded bool) LoadOrStore(k K, v V): func (m *SyncMap[K, V]) LoadOrStore(k K, v V) (actual V, loaded bool) Range(f func(k K, v V) bool): func (m *SyncMap[K, V]) Range(f func(k K, v V) bool) Store(k K, v V): func (m *SyncMap[K, V]) Store(k K, v V) ``` -------------------------------- ### Go Function: NewSyncMap API Reference Source: https://pkg.go.dev/github.com/playwright-community/playwright-go/internal/safe API documentation for the `NewSyncMap` function, which constructs and returns a new instance of the generic thread-safe `SyncMap`. ```APIDOC func NewSyncMap[K comparable, V any]() *SyncMap[K, V] Description: NewSyncMap creates a new thread-safe map ``` -------------------------------- ### Go SyncMap.LoadAndDelete Method Source: https://pkg.go.dev/github.com/playwright-community/playwright-go/@v0.5200.0/internal/safe LoadAndDelete deletes the value for a key, and returns the previous value if any. ```Go func (m *SyncMap[K, V]) LoadAndDelete(k K) (v V, loaded bool) ``` -------------------------------- ### Go SyncMap.Range Method Source: https://pkg.go.dev/github.com/playwright-community/playwright-go/@v0.5200.0/internal/safe Iterates over the key-value pairs in the SyncMap, calling the provided function `f` for each pair. Iteration stops if `f` returns false. ```Go func (m *SyncMap[K, V]) Range(f func(k K, v V) bool) ``` -------------------------------- ### Go SyncMap.LoadOrStore Method Source: https://pkg.go.dev/github.com/playwright-community/playwright-go/@v0.5200.0/internal/safe LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. ```Go func (m *SyncMap[K, V]) LoadOrStore(k K, v V) (actual V, loaded bool) ``` -------------------------------- ### Go SyncMap.Store Method Source: https://pkg.go.dev/github.com/playwright-community/playwright-go/@v0.5200.0/internal/safe Stores a key-value pair (`k`, `v`) in the SyncMap. If the key `k` already exists, its associated value will be overwritten with `v`. ```Go func (m *SyncMap[K, V]) Store(k K, v V) ``` -------------------------------- ### Load or Store in SyncMap in Go Source: https://pkg.go.dev/github.com/playwright-community/playwright-go/internal/safe Returns the existing value for the key if present. Otherwise, it stores and returns the given value. This operation is atomic, ensuring thread safety and preventing race conditions. ```Go func (m *SyncMap[K, V]) LoadOrStore(k K, v V) (actual V, loaded bool) ``` -------------------------------- ### Go SyncMap.Clear Method Source: https://pkg.go.dev/github.com/playwright-community/playwright-go/@v0.5200.0/internal/safe Clears all key-value pairs from the SyncMap, effectively making it empty. ```Go func (m *SyncMap[K, V]) Clear() ``` -------------------------------- ### Load Value from SyncMap in Go Source: https://pkg.go.dev/github.com/playwright-community/playwright-go/internal/safe Retrieves the value associated with the specified key from the SyncMap. It returns the value and a boolean indicating whether the key was found, allowing for conditional logic. ```Go func (m *SyncMap[K, V]) Load(k K) (v V, ok bool) ``` -------------------------------- ### Go SyncMap.Len Method Source: https://pkg.go.dev/github.com/playwright-community/playwright-go/@v0.5200.0/internal/safe Returns the current number of key-value pairs stored in the SyncMap. This count reflects the map's size at the time of the call. ```Go func (m *SyncMap[K, V]) Len() int ``` -------------------------------- ### Load and Delete from SyncMap in Go Source: https://pkg.go.dev/github.com/playwright-community/playwright-go/internal/safe Deletes the value for a key, and returns the previous value if any. This operation is atomic, ensuring thread safety during concurrent access. ```Go func (m *SyncMap[K, V]) LoadAndDelete(k K) (v V, loaded bool) ``` -------------------------------- ### Iterate Over SyncMap in Go Source: https://pkg.go.dev/github.com/playwright-community/playwright-go/internal/safe Iterates over the key-value pairs in the SyncMap, calling the provided function `f` for each pair. The iteration stops if `f` returns false, allowing for controlled traversal. ```Go func (m *SyncMap[K, V]) Range(f func(k K, v V) bool) ``` -------------------------------- ### Go SyncMap.Delete Method Source: https://pkg.go.dev/github.com/playwright-community/playwright-go/@v0.5200.0/internal/safe Deletes the value associated with the specified key `k` from the SyncMap. If the key does not exist, the map remains unchanged. ```Go func (m *SyncMap[K, V]) Delete(k K) ``` -------------------------------- ### Clear SyncMap in Go Source: https://pkg.go.dev/github.com/playwright-community/playwright-go/internal/safe Clears all key-value pairs from the SyncMap, effectively making it empty. This operation resets the map's state. ```Go func (m *SyncMap[K, V]) Clear() ``` -------------------------------- ### Store Value in SyncMap in Go Source: https://pkg.go.dev/github.com/playwright-community/playwright-go/internal/safe Stores a key-value pair in the SyncMap. If the key already exists, its value is updated. This operation is thread-safe for concurrent writes. ```Go func (m *SyncMap[K, V]) Store(k K, v V) ``` -------------------------------- ### Delete Key from SyncMap in Go Source: https://pkg.go.dev/github.com/playwright-community/playwright-go/internal/safe Removes the key-value pair associated with the specified key from the SyncMap. If the key does not exist, the map remains unchanged. ```Go func (m *SyncMap[K, V]) Delete(k K) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.