Documentation
¶
Overview ¶
Package goaoi implements conventient algorithms for processing iterables. It is inspired by the algorithm header from the C++ standard template library (STL for short).
Index ¶
- func AccumulateIterator[TKey any, TValue any](container ds.ReadForIndexIterator[TKey, TValue], initialAccumulator TValue, ...) TValue
- func AccumulateMap[TKey comparable, TValue comparable](container map[TKey]TValue, initialAccumulator TValue, ...) TValue
- func AccumulateSlice[T any](container []T, initialAccumulator T, binary_func func(T, T) T) T
- func AccumulateString(container string, initialAccumulator rune, binary_func func(rune, rune) rune) rune
- func AdjacentFindIteratorPred[TKey any, TValue comparable](container ds.ReadForIndexIterator[TKey, TValue], ...) (int, error)
- func AdjacentFindSlicePred[T comparable](container []T, binary_predicate func(T, T) bool) (int, error)
- func AdjacentFindStringPred(container string, binary_predicate func(byte, byte) bool) (int, error)
- func AllOfIterator[TKey any, TValue any](container ds.ReadForIndexIterator[TKey, TValue], ...) error
- func AllOfMap[TKey comparable, TValue comparable](container map[TKey]TValue, unaryPredicate func(TValue) bool) error
- func AllOfSlice[T any](container []T, unaryPredicate func(T) bool) error
- func AllOfString(container string, unaryPredicate func(rune) bool) error
- func AnyOfIterator[TKey any, TValue any](container ds.ReadForIndexIterator[TKey, TValue], ...) error
- func AnyOfMap[TKey comparable, TValue comparable](container map[TKey]TValue, unaryPredicate func(TValue) bool) error
- func AnyOfSlice[T any](container []T, unaryPredicate func(T) bool) error
- func AnyOfString(container string, unaryPredicate func(rune) bool) error
- func CountIfIterator[TKey any, TValue comparable](container ds.ReadForIndexIterator[TKey, TValue], ...) (int, error)
- func CountIfMap[TKey comparable, TValue comparable](container map[TKey]TValue, unaryPredicate func(TValue) bool) (int, error)
- func CountIfSlice[T comparable](container []T, unaryPredicate func(T) bool) (int, error)
- func CountIfString(container string, unaryPredicate func(rune) bool) (int, error)
- func DropNIterator[TKey any, TValue any](original ds.ReadForIndexIterator[TKey, TValue], n int) (ds.ReadForIndexIterator[TKey, TValue], error)
- func DropWhileIterator[TKey any, TValue any](original ds.ReadForIndexIterator[TKey, TValue], ...) (ds.ReadForIndexIterator[TKey, TValue], error)
- func DropWhileSlice[T comparable](original []T, unaryPredicate func(T) bool) ([]T, error)
- func DropWhileString(original string, unaryPredicate func(rune) bool) (string, error)
- func FillSlice[T any](arr *[]T, filler T) []T
- func FindEndSlicePred[T comparable](super []T, sub []T, binary_predicate func(T, T) bool) (int, error)
- func FindEndStringPred(super string, sub string, binary_predicate func(byte, byte) bool) (int, error)
- func FindFirstOfMapPred[TKey comparable, TValue comparable](haystack map[TKey]TValue, needles []TValue, ...) (TKey, error)
- func FindFirstOfSlicePred[T comparable](haystack []T, needles []T, binary_predicate func(T, T) bool) (int, error)
- func FindFirstOfStringPred(haystack string, needles string, binary_predicate func(rune, rune) bool) (int, error)
- func FindIfIterator[TKey any, TValue comparable](haystack ds.ReadForIndexIterator[TKey, TValue], ...) (int, error)
- func FindIfMap[TKey comparable, TValue comparable](haystack map[TKey]TValue, unaryPredicate func(TValue) bool) (TKey, error)
- func FindIfSlice[T comparable](haystack []T, unaryPredicate func(T) bool) (int, error)
- func FindIfString(haystack string, unaryPredicate func(rune) bool) (int, error)
- func ForeachIterator[TKey any, TValue any](container ds.ReadForIndexIterator[TKey, TValue], unary_func func(TValue) error) error
- func ForeachIteratorUnsafe[TKey any, TValue any](container ds.ReadForIndexIterator[TKey, TValue], unary_func func(TValue)) error
- func ForeachMap[TKey comparable, TValue comparable](container map[TKey]TValue, unary_func func(TValue) error) error
- func ForeachMapUnsafe[TKey comparable, TValue comparable](container map[TKey]TValue, unary_func func(TValue)) error
- func ForeachSlice[T any](container []T, unary_func func(T) error) error
- func ForeachSliceUnsafe[T any](container []T, unary_func func(T)) error
- func ForeachString(container string, unary_func func(rune) error) error
- func ForeachStringUnsafe(container string, unary_func func(rune)) error
- func JoinIterator[TKey any, TValue any](originals ...ds.ReadForIndexIterator[TKey, TValue]) (ds.ReadForIndexIterator[TKey, TValue], error)
- func MaxMapPred[TKey comparable, TValue constraints.Ordered](haystack map[TKey]TValue, binary_predicate func(TValue, TValue) bool) (TKey, TValue, error)
- func MaxSlicePred[T constraints.Ordered](haystack []T, binary_predicate func(T, T) bool) (int, T, error)
- func MaxStringPred[T constraints.Ordered](haystack string, binary_predicate func(rune, rune) bool) (int, rune, error)
- func MinMapPred[TKey comparable, TValue constraints.Ordered](haystack map[TKey]TValue, binary_predicate func(TValue, TValue) bool) (TKey, TValue, error)
- func MinMaxMapPred[TKey comparable, TValue constraints.Ordered](haystack map[TKey]TValue, binary_predicate_min func(TValue, TValue) bool, ...) (TKey, TKey, TValue, TValue, error)
- func MinMaxSlicePred[T constraints.Ordered](haystack []T, binary_predicate_min func(T, T) bool, ...) (int, int, T, T, error)
- func MinMaxStringPred[T constraints.Ordered](haystack []T, binary_predicate_min func(T, T) bool, ...) (int, int, T, T, error)
- func MinSlicePred[T constraints.Ordered](haystack []T, binary_predicate func(T, T) bool) (int, T, error)
- func MinStringPred[T constraints.Ordered](haystack string, binary_predicate func(rune, rune) bool) (int, rune, error)
- func MismatchSlicePred[T comparable](iterable1 []T, iterable2 []T, binary_predicate func(T, T) bool) (int, error)
- func MismatchStringPred(iterable1 string, iterable2 string, binary_predicate func(byte, byte) bool) (int, error)
- func NoneOfIterator[TKey any, TValue any](container ds.ReadForIndexIterator[TKey, TValue], ...) error
- func NoneOfMap[TKey comparable, TValue comparable](container map[TKey]TValue, unaryPredicate func(TValue) bool) error
- func NoneOfSlice[T any](container []T, unaryPredicate func(T) bool) error
- func NoneOfString(container string, unaryPredicate func(rune) bool) error
- func ReplaceIfIterator[TKey any, TValue any](original ds.ReadForIndexIterator[TKey, TValue], ...) (ds.ReadForIndexIterator[TKey, TValue], error)
- func ReplaceIfMap[TKey comparable, TValue comparable](original map[TKey]TValue, unaryPredicate func(TValue) bool, replacement TValue) (map[TKey]TValue, error)
- func ReplaceIfSlice[T comparable](original []T, unaryPredicate func(T) bool, replacement T) ([]T, error)
- func ReplaceIfString(original string, unaryPredicate func(rune) bool, replacement rune) (string, error)
- func StridedIterator[TKey any, TValue any](original ds.ReadForIndexIterator[TKey, TValue], n int) (ds.ReadForIndexIterator[TKey, TValue], error)
- func TakeIfIterator[TKey any, TValue any](original ds.ReadForIndexIterator[TKey, TValue], ...) (ds.ReadForIndexIterator[TKey, TValue], error)
- func TakeIfMap[TKey comparable, TValue comparable](original map[TKey]TValue, unaryPredicate func(TValue) bool) (map[TKey]TValue, error)
- func TakeIfSlice[T comparable](original []T, unaryPredicate func(T) bool) ([]T, error)
- func TakeIfString(original string, unaryPredicate func(rune) bool) (string, error)
- func TakeNIterator[TKey any, TValue any](original ds.ReadForIndexIterator[TKey, TValue], n int) (ds.ReadForIndexIterator[TKey, TValue], error)
- func TakeWhileIterator[TKey any, TValue any](original ds.ReadForIndexIterator[TKey, TValue], ...) (ds.ReadForIndexIterator[TKey, TValue], error)
- func TakeWhileSlice[T comparable](original []T, unaryPredicate func(T) bool) ([]T, error)
- func TakeWhileString(original string, unaryPredicate func(rune) bool) (string, error)
- func TransformCopyMap[TKey comparable, TValue comparable, TValueOut any](container map[TKey]TValue, transformer func(TValue) (TValueOut, error)) (map[TKey]TValueOut, error)
- func TransformCopyMapUnsafe[TKey comparable, TValue comparable, TValueOut any](container map[TKey]TValue, transformer func(TValue) TValueOut) (map[TKey]TValueOut, error)
- func TransformCopySlice[T any, TOut any](container []T, transformer func(T) (TOut, error)) ([]TOut, error)
- func TransformCopySliceUnsafe[T any, TOut any](container []T, transformer func(T) TOut) ([]TOut, error)
- func TransformCopyString(container string, transformer func(rune) (rune, error)) (string, error)
- func TransformCopyStringUnsafe(container string, transformer func(rune) rune) (string, error)
- func TransformIterator[TKey any, TValue any](container ds.ReadForIndexIterator[TKey, TValue], ...) (ds.ReadForIndexIterator[TKey, TValue], error)
- func TransformIteratorUnsafe[TKey any, TValue any](container ds.ReadForIndexIterator[TKey, TValue], ...) (ds.ReadForIndexIterator[TKey, TValue], error)
- func TransformMap[TKey comparable, TValue comparable](container map[TKey]TValue, transformer func(TValue) (TValue, error)) error
- func TransformMapUnsafe[TKey comparable, TValue comparable](container map[TKey]TValue, transformer func(TValue) TValue) error
- func TransformSlice[T any](container []T, transformer func(*T) error) error
- func TransformSliceUnsafe[T any](container []T, transformer func(*T)) error
- type ComparisonError
- type ElementNotFoundError
- type EmptyIterableError
- type EqualIteratorsError
- type ExecutionError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccumulateIterator ¶ added in v1.6.0
func AccumulateIterator[TKey any, TValue any](container ds.ReadForIndexIterator[TKey, TValue], initialAccumulator TValue, binary_func func(TValue, TValue) TValue) TValue
AccumulateIterator returns initialAccumulator after executing initialAccumulaator = binary_func(initialAccumulator, element) for each element.
func AccumulateMap ¶ added in v1.6.0
func AccumulateMap[TKey comparable, TValue comparable](container map[TKey]TValue, initialAccumulator TValue, binary_func func(TValue, TValue) TValue) TValue
AccumulateMap returns initialAccumulator after executing initialAccumulaator = binary_func(initialAccumulator, element) for each element. Note that the iteration order of a map is not stable.
func AccumulateSlice ¶ added in v1.6.0
func AccumulateSlice[T any](container []T, initialAccumulator T, binary_func func(T, T) T) T
AccumulateSlice returns initialAccumulator after executing initialAccumulaator = binary_func(initialAccumulator, element) for each element.
func AccumulateString ¶ added in v1.6.0
func AccumulateString(container string, initialAccumulator rune, binary_func func(rune, rune) rune) rune
AccumulateString returns initialAccumulator after executing initialAccumulaator = binary_func(initialAccumulator, element) for each element.
func AdjacentFindIteratorPred ¶ added in v0.7.0
func AdjacentFindIteratorPred[TKey any, TValue comparable](container ds.ReadForIndexIterator[TKey, TValue], binary_predicate func(TValue, TValue) bool) (int, error)
AdjacentFindIteratorPred finds the first index i where binary_predicate(container[i], container[i+1]) == true.
Possible Error values:
- EmptyIterableError
- ElementNotFoundError
func AdjacentFindSlicePred ¶
func AdjacentFindSlicePred[T comparable](container []T, binary_predicate func(T, T) bool) (int, error)
AdjacentFindSlicePred finds the first index i where binary_predicate(container[i], container[i+1]) == true.
Possible Error values:
- EmptyIterableError
- ElementNotFoundError
func AdjacentFindStringPred ¶ added in v0.7.0
AdjacentFindStringPred finds the first index i where binary_predicate(container[i], container[i+1]) == true.
Possible Error values:
- EmptyIterableError
- ElementNotFoundError
func AllOfIterator ¶ added in v0.7.0
func AllOfIterator[TKey any, TValue any](container ds.ReadForIndexIterator[TKey, TValue], unaryPredicate func(TValue) bool) error
AllOfIterator checks that unaryPredicate(val) == true for ALL val in container.
Possible Error values:
- EmptyIterableError
- ComparisonError
func AllOfMap ¶
func AllOfMap[TKey comparable, TValue comparable](container map[TKey]TValue, unaryPredicate func(TValue) bool) error
AllOfMap checks that unaryPredicate(val) == true for ALL val in container. Note that the iteration order of a map is not stable.
Possible Error values:
- EmptyIterableError
- ComparisonError
func AllOfSlice ¶
AllOfSlice checks that unaryPredicate(val) == true for ALL val in container.
Possible Error values:
- EmptyIterableError
- ComparisonError
func AllOfString ¶ added in v0.7.0
AllOfString checks that unaryPredicate(val) == true for ALL val in container.
Possible Error values:
- EmptyIterableError
- ComparisonError
func AnyOfIterator ¶ added in v0.7.0
func AnyOfIterator[TKey any, TValue any](container ds.ReadForIndexIterator[TKey, TValue], unaryPredicate func(TValue) bool) error
AnyOfIterator checks that unaryPredicate(val) == true for ANY val in container.
Possible Error values:
- EmptyIterableError
- ElementNotFoundError
func AnyOfMap ¶
func AnyOfMap[TKey comparable, TValue comparable](container map[TKey]TValue, unaryPredicate func(TValue) bool) error
AnyOfMap checks that unaryPredicate(val) == true for ANY val in container. Note that the iteration order of a map is not stable.
Possible Error values:
- EmptyIterableError
- ElementNotFoundError
func AnyOfSlice ¶
AnyOfSlice checks that unaryPredicate(val) == true for ANY val in container.
Possible Error values:
- EmptyIterableError
- ElementNotFoundError
func AnyOfString ¶ added in v0.7.0
AnyOfString checks that unaryPredicate(val) == true for ANY val in container.
Possible Error values:
- EmptyIterableError
- ElementNotFoundError
func CountIfIterator ¶ added in v0.7.0
func CountIfIterator[TKey any, TValue comparable](container ds.ReadForIndexIterator[TKey, TValue], unaryPredicate func(TValue) bool) (int, error)
CountIfIterator counts for how many val of container unaryPredicate(val) == true.
Possible Error values:
- EmptyIterableError
func CountIfMap ¶
func CountIfMap[TKey comparable, TValue comparable](container map[TKey]TValue, unaryPredicate func(TValue) bool) (int, error)
CountIfMap counts for how many val of container unaryPredicate(val) == true. Note that the iteration order of a map is not stable.
Possible Error values:
- EmptyIterableError
func CountIfSlice ¶
func CountIfSlice[T comparable](container []T, unaryPredicate func(T) bool) (int, error)
CountIfSlice counts for how many val of container unaryPredicate(val) == true.
Possible Error values:
- EmptyIterableError
func CountIfString ¶ added in v0.7.0
CountIfString counts for how many val of container unaryPredicate(val) == true.
Possible Error values:
- EmptyIterableError
func DropNIterator ¶ added in v0.7.0
func DropNIterator[TKey any, TValue any](original ds.ReadForIndexIterator[TKey, TValue], n int) (ds.ReadForIndexIterator[TKey, TValue], error)
DropNIterator returns a copy of original except the first n elements.
Possible Error values:
- EmptyIterableError
func DropWhileIterator ¶ added in v0.7.0
func DropWhileIterator[TKey any, TValue any](original ds.ReadForIndexIterator[TKey, TValue], unaryPredicate func(TValue) bool) (ds.ReadForIndexIterator[TKey, TValue], error)
DropWhileIterator returns a copy of original until the first element satisfying unaryPredicate(element) == true).
Possible Error values:
- EmptyIterableError
func DropWhileSlice ¶ added in v0.7.0
func DropWhileSlice[T comparable](original []T, unaryPredicate func(T) bool) ([]T, error)
DropWhileSlice returns a copy of original starting from first element not satisfying unaryPredicate(element) == true).
Possible Error values:
- EmptyIterableError
func DropWhileString ¶ added in v0.7.0
DropWhileString returns a copy of original starting from first element not satisfying unaryPredicate(element) == true).
Possible Error values:
- EmptyIterableError
func FillSlice ¶
func FillSlice[T any](arr *[]T, filler T) []T
FillSlice fills the array pointed to by arr with filler. all indices in the range [0, cap(*arr)[ are filled regardless of what len(*arr) is.
func FindEndSlicePred ¶
func FindEndSlicePred[T comparable](super []T, sub []T, binary_predicate func(T, T) bool) (int, error)
FindEndSlicePred finds the beginning of the last occurrence of sub in super. The elements are compared with binary_predicate.
Possible Error values:
- EmptyIterableError
- ElementNotFoundError
func FindEndStringPred ¶ added in v0.7.0
func FindEndStringPred(super string, sub string, binary_predicate func(byte, byte) bool) (int, error)
FindEndStringPred finds the beginning of the last occurrence of sub in super. The elements are compared with binary_predicate.
Possible Error values:
- EmptyIterableError
- ElementNotFoundError
func FindFirstOfMapPred ¶
func FindFirstOfMapPred[TKey comparable, TValue comparable](haystack map[TKey]TValue, needles []TValue, binary_predicate func(TValue, TValue) bool) (TKey, error)
FindFirstOfMapPred finds the first key where an element of haystack is equal to any element in needles. Note that the iteration order of a map is not stable. The elements are compared with binary_predicate.
Possible Error values:
- EmptyIterableError
- ElementNotFoundError
func FindFirstOfSlicePred ¶
func FindFirstOfSlicePred[T comparable](haystack []T, needles []T, binary_predicate func(T, T) bool) (int, error)
FindFirstOfSlicePred finds the first index where an element of haystack is equal to any element in needles. The elements are compared with binary_predicate.
Possible Error values:
- EmptyIterableError
- ElementNotFoundError
func FindFirstOfStringPred ¶ added in v0.7.0
func FindFirstOfStringPred(haystack string, needles string, binary_predicate func(rune, rune) bool) (int, error)
FindFirstOfStringPred finds the first index where an element of haystack is equal to any element in needles. The elements are compared with binary_predicate.
Possible Error values:
- EmptyIterableError
- ElementNotFoundError
func FindIfIterator ¶ added in v0.7.0
func FindIfIterator[TKey any, TValue comparable](haystack ds.ReadForIndexIterator[TKey, TValue], unaryPredicate func(TValue) bool) (int, error)
FindIfIterator finds the first index i where unaryPredicate(haystack[i]) == true.
Possible Error values:
- EmptyIterableError
- ElementNotFoundError
func FindIfMap ¶
func FindIfMap[TKey comparable, TValue comparable](haystack map[TKey]TValue, unaryPredicate func(TValue) bool) (TKey, error)
FindIfMap finds the first key where unaryPredicate(haystack[key]) == true. Note that the iteration order of a map is not stable.
Possible Error values:
- EmptyIterableError
- ElementNotFoundError
func FindIfSlice ¶
func FindIfSlice[T comparable](haystack []T, unaryPredicate func(T) bool) (int, error)
FindIfSlice finds the first index i where unaryPredicate(haystack[i]) == true.
Possible Error values:
- EmptyIterableError
- ElementNotFoundError
func FindIfString ¶ added in v0.7.0
FindIfString finds the first index i where unaryPredicate(haystack[i]) == true.
Possible Error values:
- EmptyIterableError
- ElementNotFoundError
func ForeachIterator ¶ added in v0.7.0
func ForeachIterator[TKey any, TValue any](container ds.ReadForIndexIterator[TKey, TValue], unary_func func(TValue) error) error
ForeachIterator executes unary_func(val) for each val in container. Errors returned by unary_func are propagated to the caller of ForeachSlice.
Possible Error values:
- EmptyIterableError
- ExecutionError
func ForeachIteratorUnsafe ¶ added in v0.7.0
func ForeachIteratorUnsafe[TKey any, TValue any](container ds.ReadForIndexIterator[TKey, TValue], unary_func func(TValue)) error
ForeachIteratorUnsafe executes unary_func(val) for each val in container. Errors returned by unary_func are propagated to the caller of ForeachSlice.
Possible Error values:
- EmptyIterableError
- ExecutionError
func ForeachMap ¶
func ForeachMap[TKey comparable, TValue comparable](container map[TKey]TValue, unary_func func(TValue) error) error
ForeachMap executes unary_func(val) for each val in container. Note that the iteration order of a map is not stable. Errors returned by unary_func are propagated to the caller of ForeachMap.
Possible Error values:
- EmptyIterableError
- ExecutionError
func ForeachMapUnsafe ¶
func ForeachMapUnsafe[TKey comparable, TValue comparable](container map[TKey]TValue, unary_func func(TValue)) error
ForeachMapUnsafe executes unary_func(val) for each val in container. Note that the iteration order of a map is not stable.
Possible Error values:
- EmptyIterableError
func ForeachSlice ¶
ForeachSlice executes unary_func(val) for each val in container. Errors returned by unary_func are propagated to the caller of ForeachSlice.
Possible Error values:
- EmptyIterableError
- ExecutionError
func ForeachSliceUnsafe ¶
ForeachSliceUnsafe executes unary_func(val) for each val in container.
Possible Error values:
- EmptyIterableError
func ForeachString ¶ added in v0.7.0
ForeachString executes unary_func(val) for each val in container. Errors returned by unary_func are propagated to the caller of ForeachSlice.
Possible Error values:
- EmptyIterableError
- ExecutionError
func ForeachStringUnsafe ¶ added in v0.7.0
ForeachStringUnsafe executes unary_func(val) for each val in container. Errors returned by unary_func are propagated to the caller of ForeachSlice.
Possible Error values:
- EmptyIterableError
func JoinIterator ¶ added in v0.7.0
func JoinIterator[TKey any, TValue any](originals ...ds.ReadForIndexIterator[TKey, TValue]) (ds.ReadForIndexIterator[TKey, TValue], error)
JoinIterator returns a copy of original including every element of every iterator.
Possible Error values:
- EmptyIterableError
func MaxMapPred ¶ added in v0.1.1
func MaxMapPred[TKey comparable, TValue constraints.Ordered](haystack map[TKey]TValue, binary_predicate func(TValue, TValue) bool) (TKey, TValue, error)
MaxMapPred finds the largest value in haystack. The elements are compared with binary_predicate.
Possible Error values:
- EmptyIterableError
func MaxSlicePred ¶ added in v0.1.1
func MaxSlicePred[T constraints.Ordered](haystack []T, binary_predicate func(T, T) bool) (int, T, error)
MaxSlicePred finds the largest value in haystack. The elements are compared with binary_predicate.
Possible Error values:
- EmptyIterableError
func MaxStringPred ¶ added in v0.7.0
func MaxStringPred[T constraints.Ordered](haystack string, binary_predicate func(rune, rune) bool) (int, rune, error)
MaxStringPred finds the highest value in haystack. The elements are compared with binary_predicate.
Possible Error values:
- EmptyIterableError
func MinMapPred ¶ added in v0.1.1
func MinMapPred[TKey comparable, TValue constraints.Ordered](haystack map[TKey]TValue, binary_predicate func(TValue, TValue) bool) (TKey, TValue, error)
MinMapPred finds the smallest value in haystack. The elements are compared with binary_predicate.
Possible Error values:
- EmptyIterableError
func MinMaxMapPred ¶ added in v0.1.1
func MinMaxMapPred[TKey comparable, TValue constraints.Ordered](haystack map[TKey]TValue, binary_predicate_min func(TValue, TValue) bool, binary_predicate_max func(TValue, TValue) bool) (TKey, TKey, TValue, TValue, error)
MinMaxMapPred finds the smallest and largest value in haystack. The elements are compared with binary_predicate.
Possible Error values:
- EmptyIterableError
func MinMaxSlicePred ¶ added in v0.1.1
func MinMaxSlicePred[T constraints.Ordered](haystack []T, binary_predicate_min func(T, T) bool, binary_predicate_max func(T, T) bool) (int, int, T, T, error)
MinMaxSlicePred finds the smallest and largest value in haystack. The elements are compared with binary_predicate.
Possible Error values:
- EmptyIterableError
func MinMaxStringPred ¶ added in v0.7.0
func MinMaxStringPred[T constraints.Ordered](haystack []T, binary_predicate_min func(T, T) bool, binary_predicate_max func(T, T) bool) (int, int, T, T, error)
MinMaxStringPred finds the smallest and largest value in haystack. The elements are compared with binary_predicate.
Possible Error values:
- EmptyIterableError
func MinSlicePred ¶ added in v0.1.1
func MinSlicePred[T constraints.Ordered](haystack []T, binary_predicate func(T, T) bool) (int, T, error)
MinSlicePred finds the smallest value in haystack. The elements are compared with binary_predicate.
Possible Error values:
- EmptyIterableError
func MinStringPred ¶ added in v0.7.0
func MinStringPred[T constraints.Ordered](haystack string, binary_predicate func(rune, rune) bool) (int, rune, error)
MinStringPred finds the smallest value in haystack. The elements are compared with binary_predicate.
Possible Error values:
- EmptyIterableError
func MismatchSlicePred ¶
func MismatchSlicePred[T comparable](iterable1 []T, iterable2 []T, binary_predicate func(T, T) bool) (int, error)
MismatchSlicePred finds the first index i where binary_predicate(iterable1[i], iterable2[i] == false).
Possible Error values:
- EmptyIterableError
- EqualIteratorsError
func MismatchStringPred ¶ added in v0.7.0
func MismatchStringPred(iterable1 string, iterable2 string, binary_predicate func(byte, byte) bool) (int, error)
MismatchStringPred finds the first index i where binary_predicate(iterable1[i], iterable2[i] == false).
Possible Error values:
- EmptyIterableError
- EqualIteratorsError
func NoneOfIterator ¶ added in v0.7.0
func NoneOfIterator[TKey any, TValue any](container ds.ReadForIndexIterator[TKey, TValue], unaryPredicate func(TValue) bool) error
NoneOfIterator checks that unaryPredicate(val) == true for ALL val in container.
Possible Error values:
- EmptyIterableError
- ComparisonError
func NoneOfMap ¶
func NoneOfMap[TKey comparable, TValue comparable](container map[TKey]TValue, unaryPredicate func(TValue) bool) error
NoneOfMap checks that unaryPredicate(val) == true for NO val in container. Note that the iteration order of a map is not stable.
Possible Error values:
- EmptyIterableError
- ComparisonError
func NoneOfSlice ¶
NoneOfSlice checks that unaryPredicate(val) == true for NO val in container.
Possible Error values:
- EmptyIterableError
- ComparisonError
func NoneOfString ¶ added in v0.7.0
NoneOfString checks that unaryPredicate(val) == true for NO val in container.
Possible Error values:
- EmptyIterableError
- ComparisonError
func ReplaceIfIterator ¶ added in v0.7.0
func ReplaceIfIterator[TKey any, TValue any](original ds.ReadForIndexIterator[TKey, TValue], unaryPredicate func(TValue) bool, replacement TValue) (ds.ReadForIndexIterator[TKey, TValue], error)
ReplaceIfIterator returns a copy of original with all element satisfying unaryPredicate(element) == true).
Possible Error values:
- EmptyIterableError
func ReplaceIfMap ¶ added in v0.7.0
func ReplaceIfMap[TKey comparable, TValue comparable](original map[TKey]TValue, unaryPredicate func(TValue) bool, replacement TValue) (map[TKey]TValue, error)
ReplaceIfMap returns a copy of original where each value of a key-value pair satisfying unaryPredicate(value) == true is replaced with replacement. Note that the iteration order of a map is not stable.
Possible Error values:
- EmptyIterableError
func ReplaceIfSlice ¶ added in v0.7.0
func ReplaceIfSlice[T comparable](original []T, unaryPredicate func(T) bool, replacement T) ([]T, error)
ReplaceIfSlice returns a copy of original where each element satisfying unaryPredicate(element) == true is replaced with replacement.
Possible Error values:
- EmptyIterableError
func ReplaceIfString ¶ added in v0.7.0
func ReplaceIfString(original string, unaryPredicate func(rune) bool, replacement rune) (string, error)
ReplaceIfString returns a copy of original with all element satisfying unaryPredicate(element) == true).
Possible Error values:
- EmptyIterableError
func StridedIterator ¶ added in v0.7.0
func StridedIterator[TKey any, TValue any](original ds.ReadForIndexIterator[TKey, TValue], n int) (ds.ReadForIndexIterator[TKey, TValue], error)
StridedIterator returns a copy of original including every nth element.
Possible Error values:
- EmptyIterableError
func TakeIfIterator ¶ added in v0.7.0
func TakeIfIterator[TKey any, TValue any](original ds.ReadForIndexIterator[TKey, TValue], unaryPredicate func(TValue) bool) (ds.ReadForIndexIterator[TKey, TValue], error)
TakeIfString returns a copy of original with all element satisfying unaryPredicate(element) == true).
Possible Error values:
- EmptyIterableError
func TakeIfMap ¶ added in v0.7.0
func TakeIfMap[TKey comparable, TValue comparable](original map[TKey]TValue, unaryPredicate func(TValue) bool) (map[TKey]TValue, error)
TakeIfMap returns a copy of original with all key-value pairs satisfying unaryPredicate(value) == true). Note that the iteration order of a map is not stable.
Possible Error values:
- EmptyIterableError
func TakeIfSlice ¶ added in v0.7.0
func TakeIfSlice[T comparable](original []T, unaryPredicate func(T) bool) ([]T, error)
TakeIfSlice returns a copy of original with all element satisfying unaryPredicate(element) == true).
Possible Error values:
- EmptyIterableError
func TakeIfString ¶ added in v0.7.0
TakeIfString returns a copy of original with all element satisfying unaryPredicate(element) == true).
Possible Error values:
- EmptyIterableError
func TakeNIterator ¶ added in v0.7.0
func TakeNIterator[TKey any, TValue any](original ds.ReadForIndexIterator[TKey, TValue], n int) (ds.ReadForIndexIterator[TKey, TValue], error)
TakeNIterator returns a copy of original including up to the first n elements.
Possible Error values:
- EmptyIterableError
func TakeWhileIterator ¶ added in v0.7.0
func TakeWhileIterator[TKey any, TValue any](original ds.ReadForIndexIterator[TKey, TValue], unaryPredicate func(TValue) bool) (ds.ReadForIndexIterator[TKey, TValue], error)
TakeWhileIterator returns a copy of original until the first element not satisfying unaryPredicate(element) == true).
Possible Error values:
- EmptyIterableError
func TakeWhileSlice ¶ added in v0.7.0
func TakeWhileSlice[T comparable](original []T, unaryPredicate func(T) bool) ([]T, error)
TakeWhileSlice returns a copy of original until the first element not satisfying unaryPredicate(element) == true).
Possible Error values:
- EmptyIterableError
func TakeWhileString ¶ added in v0.7.0
TakeWhileString returns a copy of original until the first element not satisfying unaryPredicate(element) == true).
Possible Error values:
- EmptyIterableError
func TransformCopyMap ¶ added in v0.7.0
func TransformCopyMap[TKey comparable, TValue comparable, TValueOut any](container map[TKey]TValue, transformer func(TValue) (TValueOut, error)) (map[TKey]TValueOut, error)
TransformCopyMap applies transformer(value) for all key-value pairs in container and and returns the newly created container. Note that the iteration order of a map is not stable. Note that the transformer can return a different type than it's input. Errors returned by transformer are propagated to the caller of TransformCopyMap.
Possible Error values:
- EmptyIterableError
- ExecutionError
func TransformCopyMapUnsafe ¶ added in v0.7.0
func TransformCopyMapUnsafe[TKey comparable, TValue comparable, TValueOut any](container map[TKey]TValue, transformer func(TValue) TValueOut) (map[TKey]TValueOut, error)
TransformCopyMapUnsafe applies transformer(value) for all key-value pairs in container and and returns the newly created container. Note that the transformer can return a different type than it's input. Note that the iteration order of a map is not stable.
Possible Error values:
- EmptyIterableError
func TransformCopySlice ¶ added in v0.7.0
func TransformCopySlice[T any, TOut any](container []T, transformer func(T) (TOut, error)) ([]TOut, error)
TransformCopySlice applies transformer(container[i]) for all i in [0, len(container)[ and and returns the newly created container. Note that the transformer can return a different type than it's input. Errors returned by transformer are propagated to the caller of TransformCopySlice.
Possible Error values:
- EmptyIterableError
- ExecutionError
func TransformCopySliceUnsafe ¶ added in v0.7.0
func TransformCopySliceUnsafe[T any, TOut any](container []T, transformer func(T) TOut) ([]TOut, error)
TransformCopySliceUnsafe applies transformer(container[i]) for all i in [0, len(container)[ and and returns the newly created container. Note that the transformer can return a different type than it's input.
Possible Error values:
- EmptyIterableError
func TransformCopyString ¶ added in v0.7.0
TransformCopySlice applies transformer(container[i]) for all i in [0, len(container)[ and and returns the newly created container. Note that the transformer can return a different type than it's input. Errors returned by transformer are propagated to the caller of TransformCopySlice.
Possible Error values:
- EmptyIterableError
- ExecutionError
func TransformCopyStringUnsafe ¶ added in v0.7.0
TransformCopySlice applies transformer(container[i]) for all i in [0, len(container)[ and and returns the newly created container. Note that the transformer can return a different type than it's input. Errors returned by transformer are propagated to the caller of TransformCopySlice.
Possible Error values:
- EmptyIterableError
- ExecutionError
func TransformIterator ¶ added in v0.7.0
func TransformIterator[TKey any, TValue any](container ds.ReadForIndexIterator[TKey, TValue], transformer func(TValue) (TValue, error)) (ds.ReadForIndexIterator[TKey, TValue], error)
TransformIterator applies transformer(&container[i]) for all i in [0, len(container)[ and stores them at container[i]. Errors returned by transformer are propagated to the caller of TransformSlice.
Possible Error values:
- EmptyIterableError
- ExecutionError
func TransformIteratorUnsafe ¶ added in v0.7.0
func TransformIteratorUnsafe[TKey any, TValue any](container ds.ReadForIndexIterator[TKey, TValue], transformer func(TValue) TValue) (ds.ReadForIndexIterator[TKey, TValue], error)
TransformIteratorUnsafe applies transformer(&container[i]) for all i in [0, len(container)[ and stores them at container[i]. Errors returned by transformer are propagated to the caller of TransformSlice.
Possible Error values:
- EmptyIterableError
- ExecutionError
func TransformMap ¶
func TransformMap[TKey comparable, TValue comparable](container map[TKey]TValue, transformer func(TValue) (TValue, error)) error
TransformMap applies transformer(value) for all key-value pairs in container and stores them at container[key]. Note that the iteration order of a map is not stable. Errors returned by transformer are propagated to the caller of TransformMap.
Possible Error values:
- EmptyIterableError
- ExecutionError
func TransformMapUnsafe ¶
func TransformMapUnsafe[TKey comparable, TValue comparable](container map[TKey]TValue, transformer func(TValue) TValue) error
TransformMapUnsafe applies transformer(value) for all key-value pairs in container and stores them at container[key]. Note that the iteration order of a map is not stable.
Possible Error values:
- EmptyIterableError
func TransformSlice ¶
TransformSlice applies transformer(&container[i]) for all i in [0, len(container)[ and stores them at container[i]. Errors returned by transformer are propagated to the caller of TransformSlice.
Possible Error values:
- EmptyIterableError
- ExecutionError
func TransformSliceUnsafe ¶
TransformSliceUnsafe applies transformer(&container[i]) for all i in [0, len(container)[ and stores them at container[i].
Possible Error values:
- EmptyIterableError
Types ¶
type ComparisonError ¶
type ComparisonError[TIndex comparable, TItem any] struct { BadItemIndex TIndex BadItem TItem }
func (ComparisonError[TIndex, TItem]) Error ¶
func (error ComparisonError[TIndex, TItem]) Error() string
type ElementNotFoundError ¶
type ElementNotFoundError struct{}
func (ElementNotFoundError) Error ¶
func (error ElementNotFoundError) Error() string
type EmptyIterableError ¶
type EmptyIterableError struct{}
func (EmptyIterableError) Error ¶
func (error EmptyIterableError) Error() string
type EqualIteratorsError ¶
type EqualIteratorsError struct{}
func (EqualIteratorsError) Error ¶
func (error EqualIteratorsError) Error() string
type ExecutionError ¶
func (ExecutionError[TIndex, TItem]) Error ¶
func (error ExecutionError[TIndex, TItem]) Error() string