Documentation
¶
Index ¶
- func False(args ...any) bool
- func FilterCollection[T any](c collections.Collection[T], filter Filter) collections.Collection[T]
- func FilterMap[K comparable, V any](m map[K]V, filter Filter) map[K]V
- func FilterSlice[T any](s []T, filter Filter) []T
- func True(args ...any) bool
- type Filter
- func And(filters ...Filter) Filter
- func ApplyToNthArgument(n int, filter Filter) Filter
- func Not(filter Filter) Filter
- func NumericallyEqualTo[T Number](n T) Filter
- func NumericallyGreaterThan[T Number](n T) Filter
- func NumericallyGreaterThanOrEqualTo[T Number](n T) Filter
- func NumericallyLessThan[T Number](n T) Filter
- func NumericallyLessThanOrEqualTo[T Number](n T) Filter
- func Or(filters ...Filter) Filter
- func Wrap(f any, staticArgs map[int]any) Filter
- type Number
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterCollection ¶
func FilterCollection[T any](c collections.Collection[T], filter Filter) collections.Collection[T]
FilterCollection filters a collection by applying a filter function to each entry. Only the entries for which the filter function returns true are kept in the copy. The original collection is not modified. Note that the entries are not deep-copied.
func FilterMap ¶
func FilterMap[K comparable, V any](m map[K]V, filter Filter) map[K]V
FilterMap filters a map by applying a filter function to each key-value pair. Only the entries for which the filter function returns true are kept in the copy. The original map is not modified. Passes the key as first and the value as second argument into the filter function. Note that the values are not deep-copied.
func FilterSlice ¶
FilterSlice filters a slice by applying a filter function to each entry. Only the entries for which the filter function returns true are kept the copy. The original slice is not modified. Note that the entries are not deep-copied.
Types ¶
type Filter ¶
func ApplyToNthArgument ¶
ApplyToNthArgument applies feeds only the nth argument of the given arguments to the given filter. Indexing starts with 0.
func NumericallyEqualTo ¶
NumericallyEqualTo returns a Filter that returns true for any value equal to n. The Filter panics if the value is not a number.
func NumericallyGreaterThan ¶
NumericallyGreaterThan returns a Filter that returns true for any value greater than n. The Filter panics if the value is not a number.
func NumericallyGreaterThanOrEqualTo ¶
NumericallyGreaterThanOrEqualTo returns a Filter that returns true for any value greater or equal to n. The Filter panics if the value is not a number.
func NumericallyLessThan ¶
NumericallyLessThan returns a Filter that returns true for any value less than n. The Filter panics if the value is not a number.
func NumericallyLessThanOrEqualTo ¶
NumericallyLessThanOrEqualTo returns a Filter that returns true for any value less or equal to n. The Filter panics if the value is not a number.
func Wrap ¶
Wrap takes a function that returns a bool and turns it into a filter. If staticArgs is not nil or empty, the provided values are passed to the function at the given positions when the filter is called. This function panics in several cases: - the given value is not a function - the given function does not return a bool as first return value (further return values are ignored) - the args when calling the filter do not match the function's signature - the indices of the staticArgs are out of bounds for the function's signature
type Number ¶
type Number interface { constraints.Integer | constraints.Float }