filter method

Map<K, V> filter(
  1. bool test(
    1. K key,
    2. V value
    )
)

根据过滤条件返回一个新的Map

Implementation

Map<K, V> filter(bool Function(K key, V value) test) {
  Map<K, V> newMap = {};
  for (K k in keys) {
    if (test(k, this[k] as V)) {
      newMap[k] = this[k] as V;
    }
  }
  return newMap;
}