Home > @silence_zhpf/utils > HashMap > filter
此函数根据给定条件过滤 HashMap 中的键值对,并返回过滤后的对的新 HashMap。
Signature:
filter(fn: (value: [T, U], index: number, array: Array<[T, U]>) => boolean): HashMap<T, U>;
| Parameter | Type | Description |
|---|---|---|
| fn | (value: [T, U], index: number, array: Array<[T, U]>) => boolean | 接受三个参数的函数:第一个参数是一个类型为[T,U]的元组,第二个参数是一个整数,第三个参数是一个数组。 |
Returns:
HashMap<T, U>
filter 方法返回过滤键值对后的 HashMap 类的新实例。