Documentation
¶
Index ¶
- type MapEntry
- type OrderedMap
- func (m *OrderedMap[K, V]) Clear()
- func (m *OrderedMap[K, V]) Clone() *OrderedMap[K, V]
- func (m *OrderedMap[K, V]) Delete(key K) (V, bool)
- func (m *OrderedMap[K, V]) Entries() iter.Seq2[K, V]
- func (m *OrderedMap[K, V]) Get(key K) (V, bool)
- func (m *OrderedMap[K, V]) GetOrZero(key K) V
- func (m *OrderedMap[K, V]) Has(key K) bool
- func (m *OrderedMap[K, V]) Keys() iter.Seq[K]
- func (m OrderedMap[K, V]) MarshalJSON() ([]byte, error)
- func (m *OrderedMap[K, V]) Set(key K, value V)
- func (m *OrderedMap[K, V]) Size() int
- func (m *OrderedMap[K, V]) UnmarshalJSON(data []byte) error
- func (m *OrderedMap[K, V]) UnmarshalJSONFrom(dec *jsontext.Decoder) error
- func (m *OrderedMap[K, V]) Values() iter.Seq[V]
- type OrderedSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MapEntry ¶
type MapEntry[K comparable, V any] struct { Key K Value V }
type OrderedMap ¶
type OrderedMap[K comparable, V any] struct { // contains filtered or unexported fields }
OrderedMap is an insertion ordered map.
func NewOrderedMapFromList ¶
func NewOrderedMapFromList[K comparable, V any](items []MapEntry[K, V]) *OrderedMap[K, V]
func NewOrderedMapWithSizeHint ¶
func NewOrderedMapWithSizeHint[K comparable, V any](hint int) *OrderedMap[K, V]
NewOrderedMapWithSizeHint creates a new OrderedMap with a hint for the number of elements it will contain.
func (*OrderedMap[K, V]) Clear ¶
func (m *OrderedMap[K, V]) Clear()
Clear removes all key-value pairs from the map. The space allocated for the map will be reused.
func (*OrderedMap[K, V]) Clone ¶
func (m *OrderedMap[K, V]) Clone() *OrderedMap[K, V]
Clone returns a shallow copy of the map.
func (*OrderedMap[K, V]) Delete ¶
func (m *OrderedMap[K, V]) Delete(key K) (V, bool)
Delete removes a key-value pair from the map.
func (*OrderedMap[K, V]) Entries ¶
func (m *OrderedMap[K, V]) Entries() iter.Seq2[K, V]
Entries returns an iterator over the key-value pairs in the map.
func (*OrderedMap[K, V]) Get ¶
func (m *OrderedMap[K, V]) Get(key K) (V, bool)
Get retrieves a value from the map.
func (*OrderedMap[K, V]) GetOrZero ¶
func (m *OrderedMap[K, V]) GetOrZero(key K) V
GetOrZero retrieves a value from the map, or returns the zero value of the value type if the key is not present.
func (*OrderedMap[K, V]) Has ¶
func (m *OrderedMap[K, V]) Has(key K) bool
Has returns true if the map contains the key.
func (*OrderedMap[K, V]) Keys ¶
func (m *OrderedMap[K, V]) Keys() iter.Seq[K]
Keys returns an iterator over the keys in the map. A slice of the keys can be obtained by calling `slices.Collect`.
func (OrderedMap[K, V]) MarshalJSON ¶
func (m OrderedMap[K, V]) MarshalJSON() ([]byte, error)
func (*OrderedMap[K, V]) Set ¶
func (m *OrderedMap[K, V]) Set(key K, value V)
Set sets a key-value pair in the map.
func (*OrderedMap[K, V]) Size ¶
func (m *OrderedMap[K, V]) Size() int
Size returns the number of key-value pairs in the map.
func (*OrderedMap[K, V]) UnmarshalJSON ¶
func (m *OrderedMap[K, V]) UnmarshalJSON(data []byte) error
func (*OrderedMap[K, V]) UnmarshalJSONFrom ¶
func (m *OrderedMap[K, V]) UnmarshalJSONFrom(dec *jsontext.Decoder) error
func (*OrderedMap[K, V]) Values ¶
func (m *OrderedMap[K, V]) Values() iter.Seq[V]
Values returns an iterator over the values in the map. A slice of the values can be obtained by calling `slices.Collect`.
type OrderedSet ¶
type OrderedSet[T comparable] struct { // contains filtered or unexported fields }
OrderedSet an insertion ordered set.
func NewOrderedSetWithSizeHint ¶
func NewOrderedSetWithSizeHint[T comparable](hint int) *OrderedSet[T]
NewOrderedSetWithSizeHint creates a new OrderedSet with a hint for the number of elements it will contain.
func (*OrderedSet[T]) Clear ¶
func (s *OrderedSet[T]) Clear()
Clear removes all elements from the set. The space allocated for the set will be reused.
func (*OrderedSet[T]) Clone ¶
func (s *OrderedSet[T]) Clone() *OrderedSet[T]
Clone returns a shallow copy of the set.
func (*OrderedSet[T]) Delete ¶
func (s *OrderedSet[T]) Delete(value T) bool
Delete removes a value from the set.
func (*OrderedSet[T]) Has ¶
func (s *OrderedSet[T]) Has(value T) bool
Has returns true if the set contains the value.
func (*OrderedSet[T]) Size ¶
func (s *OrderedSet[T]) Size() int
Size returns the number of elements in the set.
func (*OrderedSet[T]) Values ¶
func (s *OrderedSet[T]) Values() iter.Seq[T]
Values returns an iterator over the values in the set.