Open
Description
Map.filterKeys is deprecated as the moment. Its deprecation message says:
Use .view.filterKeys(f). A future version will include a strict version of this method (for now, .view.filterKeys(p).toMap).
The suggested .view.filterKeys(p).toMap
is not very efficient, it rebuilds the whole map. Could a strict version be added as promised by the deprecation warning?
Following workaround provides a more efficient solution for those interested:
implicit class MoreMapOps[K, V](private val m: Map[K, V]) extends AnyVal {
def filterKeysStrict(predicate: K => Boolean): Map[K, V] = {
m.removedAll(m.keys.filterNot(predicate))
}
}
Metadata
Metadata
Assignees
Labels
No labels