Documentation ¶
Index ¶
- func FirstValueOf[KT comparable, VT any](m map[KT]VT) (_ VT, ok bool)
- func ForEachKV[K comparable, V any](obj map[K]V, do func(K, V))
- func ForEachKey[K comparable, V any](obj map[K]V, do func(K))
- func ForEachValue[K comparable, V any](obj map[K]V, do func(V))
- func MapFind[KT comparable, VT, CT any](m Map[KT, VT], criteria func(VT) (CT, bool)) (_ CT)
- func ParallelForEach[T any](obj []T, do func(T))
- func ParallelForEachKV[K comparable, V any](obj map[K]V, do func(K, V))
- func ParallelForEachKey[K comparable, V any](obj map[K]V, do func(K))
- func ParallelForEachValue[K comparable, V any](obj map[K]V, do func(V))
- type Map
- func (m Map[KT, VT]) Has(k KT) bool
- func (m Map[KT, VT]) MergeFrom(other Map[KT, VT]) Map[KT, VT]
- func (m Map[KT, VT]) RangeAll(do func(k KT, v VT))
- func (m Map[KT, VT]) RangeAllParallel(do func(k KT, v VT))
- func (m Map[KT, VT]) RemoveAll(criteria func(VT) bool)
- func (m Map[KT, VT]) String() string
- func (m Map[KT, VT]) UnmarshalFromYAML(data []byte) E.NestedError
- type Slice
- func (s *Slice[T]) Add(e T) *Slice[T]
- func (s *Slice[T]) AddRange(other *Slice[T]) *Slice[T]
- func (s *Slice[T]) Empty() bool
- func (s *Slice[T]) Filter(f func(T) bool) *Slice[T]
- func (s *Slice[T]) ForEach(do func(T))
- func (s *Slice[T]) Get(i int) T
- func (s *Slice[T]) Iterator() []T
- func (s *Slice[T]) Map(m func(T) T) *Slice[T]
- func (s *Slice[T]) NotEmpty() bool
- func (s *Slice[T]) Pop() T
- func (s *Slice[T]) Remove(criteria func(T) bool)
- func (s *Slice[T]) SafeAdd(e T) *Slice[T]
- func (s *Slice[T]) SafeAddRange(other *Slice[T]) *Slice[T]
- func (s *Slice[T]) SafePop() T
- func (s *Slice[T]) SafeRemove(criteria func(T) bool)
- func (s *Slice[T]) Set(i int, v T)
- func (s *Slice[T]) Size() int
- func (s *Slice[T]) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FirstValueOf ¶
func FirstValueOf[KT comparable, VT any](m map[KT]VT) (_ VT, ok bool)
func ForEachKV ¶
func ForEachKV[K comparable, V any](obj map[K]V, do func(K, V))
func ForEachKey ¶
func ForEachKey[K comparable, V any](obj map[K]V, do func(K))
func ForEachValue ¶
func ForEachValue[K comparable, V any](obj map[K]V, do func(V))
func MapFind ¶
func MapFind[KT comparable, VT, CT any](m Map[KT, VT], criteria func(VT) (CT, bool)) (_ CT)
MapFind iterates over the map and returns the first value that satisfies the given criteria. The iteration is stopped once a value is found. If no value satisfies the criteria, the function returns the zero value of CT.
The criteria function takes a value of type VT and returns a value of type CT and a boolean indicating whether the value satisfies the criteria. The boolean value is used to determine whether the iteration should be stopped.
The function is safe for concurrent use.
func ParallelForEach ¶
func ParallelForEach[T any](obj []T, do func(T))
func ParallelForEachKV ¶
func ParallelForEachKV[K comparable, V any](obj map[K]V, do func(K, V))
func ParallelForEachKey ¶
func ParallelForEachKey[K comparable, V any](obj map[K]V, do func(K))
func ParallelForEachValue ¶
func ParallelForEachValue[K comparable, V any](obj map[K]V, do func(V))
Types ¶
type Map ¶
type Map[KT comparable, VT any] struct { *xsync.MapOf[KT, VT] }
func NewMapFrom ¶
func NewMapFrom[KT comparable, VT any](m map[KT]VT) (res Map[KT, VT])
func NewMapOf ¶
func NewMapOf[KT comparable, VT any](options ...func(*xsync.MapConfig)) Map[KT, VT]
func (Map[KT, VT]) MergeFrom ¶
MergeFrom merges the contents of another Map into this one, ignoring duplicated keys.
Parameters:
other: Map of values to add from
Returns:
Map of duplicated keys-value pairs
func (Map[KT, VT]) RangeAll ¶
func (m Map[KT, VT]) RangeAll(do func(k KT, v VT))
RangeAll calls the given function for each key-value pair in the map.
Parameters:
do: function to call for each key-value pair
Returns:
nothing
func (Map[KT, VT]) RangeAllParallel ¶
func (m Map[KT, VT]) RangeAllParallel(do func(k KT, v VT))
RangeAllParallel calls the given function for each key-value pair in the map, in parallel. The map is not safe for modification from within the function.
Parameters:
do: function to call for each key-value pair
Returns:
nothing
func (Map[KT, VT]) RemoveAll ¶
RemoveAll removes all key-value pairs from the map where the value matches the given criteria.
Parameters:
criteria: function to determine whether a value should be removed
Returns:
nothing
func (Map[KT, VT]) UnmarshalFromYAML ¶
func (m Map[KT, VT]) UnmarshalFromYAML(data []byte) E.NestedError
UnmarshalFromYAML unmarshals a yaml byte slice into the map.
It overwrites all existing key-value pairs in the map.
Parameters:
data: yaml byte slice to unmarshal
Returns:
error: if the unmarshaling fails
type Slice ¶
type Slice[T any] struct { // contains filtered or unexported fields }