Documentation
¶
Index ¶
- func MapFind[KT comparable, VT, CT any](m Map[KT, VT], criteria func(VT) (CT, bool)) (_ CT)
- type Map
- func (m Map[KT, VT]) CollectErrors(do func(k KT, v VT) error) []error
- func (m Map[KT, VT]) CollectErrorsParallel(do func(k KT, v VT) error) []error
- 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]) String() string
- type Set
- func (set Set[T]) Add(v T)
- func (set Set[T]) Clear()
- func (set Set[T]) Contains(v T) bool
- func (set Set[T]) IsEmpty() bool
- func (set Set[T]) Range(f func(T) bool)
- func (set Set[T]) RangeAll(f func(T))
- func (set Set[T]) RangeAllParallel(f func(T))
- func (set Set[T]) Remove(v T)
- func (set Set[T]) Size() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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.
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]) CollectErrors ¶
CollectErrors calls the given function for each key-value pair in the map, then returns a slice of errors collected.
func (Map[KT, VT]) CollectErrorsParallel ¶
CollectErrors calls the given function for each key-value pair in the map, then returns a slice of errors collected.
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
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
func NewSet ¶
func NewSet[T comparable]() Set[T]
func (Set[T]) RangeAllParallel ¶
func (set Set[T]) RangeAllParallel(f func(T))