utils

Home > @silence_zhpf/utils > HashSet > filter

HashSet.filter() method

此函数根据给定条件过滤 HashSet 的元素,并返回包含过滤元素的新 HashSet。

Signature:

filter(fn: (value: T, index: number, array: T[]) => boolean): HashSet<T>;

Parameters

Parameter Type Description
fn (value: T, index: number, array: T[]) => boolean 此函数用作过滤器函数,以确定 HashSet 的哪些元素应包含在结果中。

Returns:

HashSet<T>

HashSet 类的新实例,其中包含基于提供的函数过滤的元素。