Documentation
¶
Index ¶
- Variables
- func ContainsKey[K comparable, V any](m Map[K, V], target K) bool
- type Map
- type OrderMap
- func (s OrderMap[K, V]) ByKey(key K) (V, bool)
- func (s *OrderMap[K, V]) Delete(key K) (bool, error)
- func (s OrderMap[K, V]) Entry() iter.Seq2[K, V]
- func (s OrderMap[K, V]) IndexOf(key K) (uint32, bool)
- func (s *OrderMap[K, V]) Insert(key K, value V) (bool, error)
- func (s OrderMap[K, V]) Key() iter.Seq[K]
- func (s *OrderMap[K, V]) Reset() error
- func (s OrderMap[K, V]) Size() uint32
- func (s OrderMap[K, V]) Value() iter.Seq[V]
- type SortMap
- func (s SortMap[K, V]) ByKey(key K) (V, bool)
- func (s *SortMap[K, V]) Delete(key K) (bool, error)
- func (s SortMap[K, V]) Entry() iter.Seq2[K, V]
- func (s SortMap[K, V]) IndexOf(key K) (uint32, bool)
- func (s *SortMap[K, V]) Insert(key K, value V) (bool, error)
- func (s SortMap[K, V]) Key() iter.Seq[K]
- func (s *SortMap[K, V]) Reset() error
- func (s SortMap[K, V]) Size() uint32
- func (s SortMap[K, V]) Value() iter.Seq[V]
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrFullMap occurs when a map is full. Readers must return this // error as is and not wrap it as callers are expected to check for // this error with the == operator. // // Format: // "map is full" ErrFullMap error = errors.New("map is full") )
Functions ¶
func ContainsKey ¶
func ContainsKey[K comparable, V any](m Map[K, V], target K) bool
ContainsKey checks if the map contains the given key.
Parameters:
- m: The map to check.
- target: The key to check for.
Returns:
- bool: True if the map contains the key, false otherwise.
Types ¶
type Map ¶
type Map[K comparable, V any] interface { // Insert adds a key-value pair to the map. If the key already // exists, the value is updated and the result (false, nil) is // returned. // // Parameters: // - key: The key of the pair. // - value: The value of the pair. // // Returns: // - bool: A boolean indicating if the key already exists in the // map. // - error: An error if the key cannot be added to the map. // // Errors: // - common.ErrNilReceiver: If the receiver is nil. // - any other error: Implementation-dependent. Insert(key K, value V) (bool, error) // ByKey returns the value associated with the given key. // // Parameters: // - key: The key of the pair. // // Returns: // - V: The value associated with the key. // - bool: A boolean indicating if the key exists in the map. ByKey(key K) (V, bool) // Key returns a sequence of keys in the map. The order of the // returned keys is undefined. // // Returns: // - iter.Seq[K]: A sequence of keys in the map. Never returns nil. Key() iter.Seq[K] // Value returns a sequence of values in the map. The order of the // returned values is undefined. // // Returns: // - iter.Seq[V]: A sequence of values in the map. Never returns // nil. Value() iter.Seq[V] // Entry returns a sequence of key-value pairs in the map. The order // of the returned pairs is undefined. // // Returns: // - iter.Seq2[K, V]: A sequence of key-value pairs in the map. // Never returns nil. Entry() iter.Seq2[K, V] // Reset resets the map for reuse. // // Returns: // - error: An error if the map could not be reset. // // Errors: // - common.ErrNilReceiver: If the receiver is nil. // - any other error: Implementation-dependent. Reset() error // Delete removes the key-value pair with the given key from the // map. // // Parameters: // - key: The key of the pair to remove. // // Returns: // - bool: A boolean indicating if the key was found in the map. // - error: An error if the key cannot be removed from the map. // // Errors: // - common.ErrNilReceiver: If the receiver is nil. // - any other error: Implementation-dependent. Delete(key K) (bool, error) }
Map is an interface that represents a map.
type OrderMap ¶
type OrderMap[K comparable, V any] struct { // contains filtered or unexported fields }
OrderMap is a map that keeps the keys in order of insertion.
An empty OrderMap can be created with either the `var o OrderMap[K, V]` syntax or the `o := new(OrderMap[K, V])` constructor.
func (OrderMap[K, V]) IndexOf ¶
IndexOf returns the index of the provided key.
Parameters:
- key: The key to search for.
Returns:
- uint32: The index of the key.
- bool: True if the key was found, false otherwise.
type SortMap ¶
SortMap is a map that keeps the keys in order using the < operator.
An empty SortMap can be created with either the `var o SortMap[K, V]` syntax or the `o := new(SortMap[K, V])` constructor.
func (SortMap[K, V]) IndexOf ¶
IndexOf returns the index of the provided key.
Parameters:
- key: The key to search for.
Returns:
- uint32: The index of the key.
- bool: True if the key was found, false otherwise.
Click to show internal directories.
Click to hide internal directories.