Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterByNegativeWeight ¶
FilterByNegativeWeight is a function that iterates over the slice and applies the weight function to each element. The returned slice contains the elements with the minimum weight. If multiple elements have the same minimum weight, they are all returned.
Parameters:
- S: slice of elements.
- weightFunc: function that takes an element and returns an integer.
Returns:
- []T: slice of elements with the minimum weight.
func FilterByPositiveWeight ¶
FilterByPositiveWeight is a function that iterates over the slice and applies the weight function to each element. The returned slice contains the elements with the maximum weight. If multiple elements have the same maximum weight, they are all returned.
Parameters:
- S: slice of elements.
- weightFunc: function that takes an element and returns an integer.
Returns:
- []T: slice of elements with the maximum weight.
func SliceFilter ¶
func SliceFilter[T any](S []T, filter PredicateFilter[T]) []T
SliceFilter is a function that iterates over the slice and applies the filter function to each element. The returned slice contains the elements that satisfy the filter function.
Parameters:
- S: slice of elements.
- filter: function that takes an element and returns a bool.
Returns:
- []T: slice of elements that satisfy the filter function.
Types ¶
type PredicateFilter ¶
PredicateFilter is a type that defines a slice filter function.
Parameters:
- T: The type of the elements in the slice.
Returns:
- bool: True if the element satisfies the filter function, otherwise false.
func Intersect ¶
func Intersect[T any](funcs ...PredicateFilter[T]) PredicateFilter[T]
Intersect returns a PredicateFilter function that checks if an element satisfies all the PredicateFilter functions in funcs. It returns false as soon as it finds a function in funcs that the element does not satisfy.
Parameters:
- funcs: A slice of PredicateFilter functions.
Returns:
- PredicateFilter: A PredicateFilter function that checks if a element satisfies all the PredicateFilter functions in funcs.
func Union ¶
func Union[T any](funcs ...PredicateFilter[T]) PredicateFilter[T]
Union returns a PredicateFilter function that checks if an element satisfies at least one of the PredicateFilter functions in funcs. It returns true as soon as it finds a function in funcs that the element satisfies.
Parameters:
- funcs: A slice of PredicateFilter functions.
Returns:
- PredicateFilter: A PredicateFilter function that checks if a element satisfies at least one of the PredicateFilter functions in funcs.