diff options
author | Paul Phillips <paulp@improving.org> | 2009-05-19 11:15:15 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-05-19 11:15:15 +0000 |
commit | 54384172fe0a5a926a133f46aed0653bb59b054d (patch) | |
tree | f2b112041cb6fc954a1f1d6e5ad970b3d65482de /src/library | |
parent | 924b4a982cc772e062c109b3d801531dcb31017a (diff) | |
download | scala-54384172fe0a5a926a133f46aed0653bb59b054d.tar.gz scala-54384172fe0a5a926a133f46aed0653bb59b054d.tar.bz2 scala-54384172fe0a5a926a133f46aed0653bb59b054d.zip |
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)
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/collection/generic/MapTemplate.scala | 7 |
1 files changed, 1 insertions, 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. */ |