MapExt

package
v0.2.35 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapFilter

func MapFilter[T comparable, E any](S map[T]E, filter PredicateFilter[T, E]) map[T]E

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

type PredicateFilter[T comparable, E any] func(T, E) bool

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 comparable, E any](funcs ...PredicateFilter[T, E]) PredicateFilter[T, E]

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 comparable, E any](funcs ...PredicateFilter[T, E]) PredicateFilter[T, E]

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL