From 54384172fe0a5a926a133f46aed0653bb59b054d Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 19 May 2009 11:15:15 +0000 Subject: Modified filterKeys to return the same type of ... Modified filterKeys to return the same type of Map as it was called upon. If this method is doing something important it should probably be documented, because right now it looks rather redundant with filter: map filterKeys (_ < 10) map filter (x => x._1 < 10) --- src/library/scala/collection/generic/MapTemplate.scala | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/library/scala/collection/generic/MapTemplate.scala b/src/library/scala/collection/generic/MapTemplate.scala index a3260cc9b0..4f4830d65c 100644 --- a/src/library/scala/collection/generic/MapTemplate.scala +++ b/src/library/scala/collection/generic/MapTemplate.scala @@ -162,12 +162,7 @@ self => /** A map view consisting only of those key value pairs where the key satisfies a given * predicate `p`. */ - def filterKeys(p: A => Boolean) = new DefaultMap[A, B] { - override def foreach[C](f: ((A, B)) => C): Unit = for (kv <- self) if (p(kv._1)) f(kv) - def elements = self.elements.filter(kv => p(kv._1)) - override def contains(key: A) = self.contains(key) && p(key) - def get(key: A) = if (!p(key)) None else self.get(key) - } + def filterKeys(p: A => Boolean): This = this filter (kv => p(kv._1)) /** A map view resulting from applying a given function `f` to each value. */ -- cgit v1.2.3