Documentation ¶
Index ¶
- type Map
- func (m *Map[K, V]) All() iterate.Seq2[K, V]
- func (m *Map[K, V]) DecodeField(dec codec.Decoder, k K) error
- func (m *Map[K, V]) Delete(k K) (deleted bool)
- func (m *Map[K, V]) Get(k K) (v V)
- func (m *Map[K, V]) GetOK(k K) (v V, ok bool)
- func (m *Map[K, V]) Len() int
- func (m *Map[K, V]) Set(k K, v V) (replaced bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
Map represents an ordered map of key-value pairs. Use the All method to iterate over pairs in the order they were added. The zero value of Map is ready to use. Methods on Map are not safe for concurrent use and must be protected by a synchronization mechanism.
func (*Map[K, V]) All ¶
All returns a sequence that iterates over all items in m. It is safe to add or delete items from the map while iterating. New items added to the map will be yielded, deleted items will not.
func (*Map[K, V]) DecodeField ¶
DecodeField implements the codec.FieldDecoder interface (if K == string).
func (*Map[K, V]) Delete ¶
Delete deletes key k from the map. It returns true if k was present in the map and deleted.
func (*Map[K, V]) Get ¶
func (m *Map[K, V]) Get(k K) (v V)
Get returns a value of type V if it exists in the map, otherwise the zero value.
func (*Map[K, V]) GetOK ¶
GetOK returns a value of type V if it exists in the map, otherwise the zero value, and a boolean value that expresses whether k is present in the map.
func (*Map[K, V]) Set ¶
Set sets the value of k to v. If k is not present, the value is appended to the end. If k is already present in the map, its value is replaced. To guarantee the value is appended to the end, call Delete before calling Set. It returns true if k was present in the map and its value was replaced.