Documentation ¶
Index ¶
- type EnumerableWithKey
- type Iterator
- type Map
- func (m *Map[K, V]) All(f func(k K, v V) bool) bool
- func (m *Map[K, V]) Any(f func(k K, v V) bool) bool
- func (m *Map[K, V]) Clear()
- func (m *Map[K, V]) Each(f func(k K, v V))
- func (m *Map[K, V]) Empty() bool
- func (m *Map[K, V]) Filter(f func(k K, v V) bool) *Map[K, V]
- func (m *Map[K, V]) Find(f func(k K, v V) bool) (_ K, _ V)
- func (m *Map[K, V]) FromJSON(data []byte) error
- func (m *Map[K, V]) Get(key K) (value V, ok bool)
- func (m *Map[K, V]) Iterator() *Iterator[K, V]
- func (m *Map[K, V]) Keys() []K
- func (m *Map[K, V]) Put(key K, value V)
- func (m *Map[K, V]) Remove(key K)
- func (m *Map[K, V]) Size() int
- func (m *Map[K, V]) String() string
- func (m *Map[K, V]) ToJSON() ([]byte, error)
- func (m *Map[K, V]) Values() []V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EnumerableWithKey ¶
type EnumerableWithKey[K comparable, V any] interface { Filter(f func(k K, v V) bool) *Map[K, V] containers.EnumerableWithKey[K, V] }
type Iterator ¶
type Iterator[K comparable, V any] struct { // contains filtered or unexported fields }
Iterator is an iterator for the linked hash map.
func (*Iterator[K, V]) Begin ¶
func (it *Iterator[K, V]) Begin()
Begin resets the iterator to its initial state (one-before-first) Call Next() to fetch the first element if any.
func (*Iterator[K, V]) End ¶
func (it *Iterator[K, V]) End()
End moves the iterator past the last element (one-past-the-end). Call Prev() to fetch the last element if any.
func (*Iterator[K, V]) First ¶
First moves the iterator to the first element and returns true if there was a first element in the container. If the iterator was positioned before the first element, it will be moved to the first element. If the first element has not been loaded, loading will be performed.
func (*Iterator[K, V]) Key ¶
func (it *Iterator[K, V]) Key() K
Key returns the current key of the iterator.
func (*Iterator[K, V]) Last ¶
Last moves the iterator to the last element and returns true if there was a last element in the container. If the iterator was positioned before the last element, it will be moved to the last element. If the last element has not been loaded, loading will be performed.
func (*Iterator[K, V]) Next ¶
Next moves the iterator to the next element and returns true if there was a next element in the container.
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
Map is a hash table that uses a linked list for collision resolution. LinkedHashMap keeps a doubly-linked list of all entries in the map.
func Map_ ¶
func Map_[K comparable, V1 any, V2 any](m *Map[K, V1], f func(k K, v V1) V2) *Map[K, V2]
Map returns a new container with the results of applying the given function to each element in this container.
func (*Map[K, V]) All ¶
All passes each element of the container to the given function and returns true if the function returns true for all elements.
func (*Map[K, V]) Any ¶
Any passes each element of the container to the given function and returns true if the function ever returns true for any element.
func (*Map[K, V]) Clear ¶
func (m *Map[K, V]) Clear()
Clear removes all key-value pairs from the map.
func (*Map[K, V]) Each ¶
func (m *Map[K, V]) Each(f func(k K, v V))
Each calls the given function for each element.
func (*Map[K, V]) Filter ¶
Filter returns a new container with all elements that the given predicate returns true for.
func (*Map[K, V]) Find ¶
Find returns the first value that the given predicate returns true for. If none matches, then ok is false.
func (*Map[K, V]) Put ¶
func (m *Map[K, V]) Put(key K, value V)
Put adds a new key-value pair to the map.
func (*Map[K, V]) Remove ¶
func (m *Map[K, V]) Remove(key K)
Remove removes the key-value pair with the given key.