diff options
author | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2011-07-26 17:06:49 +0000 |
---|---|---|
committer | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2011-07-26 17:06:49 +0000 |
commit | 68031b3af11a2f79b186607f44d5c327051d19bd (patch) | |
tree | b0381baa1311819156faa5e7dce45f946b6fd38d /src/library/scala/collection/GenMapLike.scala | |
parent | 1ad15b1f50364dc42e06117bf551159adea25312 (diff) | |
download | scala-68031b3af11a2f79b186607f44d5c327051d19bd.tar.gz scala-68031b3af11a2f79b186607f44d5c327051d19bd.tar.bz2 scala-68031b3af11a2f79b186607f44d5c327051d19bd.zip |
Adding the missing ParMap and GenMap methods.
No review.
Diffstat (limited to 'src/library/scala/collection/GenMapLike.scala')
-rw-r--r-- | src/library/scala/collection/GenMapLike.scala | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/library/scala/collection/GenMapLike.scala b/src/library/scala/collection/GenMapLike.scala index 2bbcc8f4f5..6060087d54 100644 --- a/src/library/scala/collection/GenMapLike.scala +++ b/src/library/scala/collection/GenMapLike.scala @@ -29,10 +29,78 @@ trait GenMapLike[A, +B, +Repr] extends GenIterableLike[(A, B), Repr] with Equals def +[B1 >: B](kv: (A, B1)): GenMap[A, B1] def - (key: A): Repr + // This hash code must be symmetric in the contents but ought not // collide trivially. override def hashCode() = util.MurmurHash.symmetricHash(seq, Map.hashSeed) + /** Returns the value associated with a key, or a default value if the key is not contained in the map. + * @param key the key. + * @param default a computation that yields a default value in case no binding for `key` is + * found in the map. + * @tparam B1 the result type of the default computation. + * @return the value associated with `key` if it exists, + * otherwise the result of the `default` computation. + * @usecase def getOrElse(key: A, default: => B): B + */ + def getOrElse[B1 >: B](key: A, default: => B1): B1 + + /** Tests whether this map contains a binding for a key. + * + * @param key the key + * @return `true` if there is a binding for `key` in this map, `false` otherwise. + */ + def contains(key: A): Boolean + + /** Tests whether this map contains a binding for a key. This method, + * which implements an abstract method of trait `PartialFunction`, + * is equivalent to `contains`. + * + * @param key the key + * @return `true` if there is a binding for `key` in this map, `false` otherwise. + */ + def isDefinedAt(key: A): Boolean + + def keySet: GenSet[A] + + /** Collects all keys of this map in an iterable collection. + * + * @return the keys of this map as an iterable. + */ + def keys: GenIterable[A] + + /** Collects all values of this map in an iterable collection. + * + * @return the values of this map as an iterable. + */ + def values: GenIterable[B] + + /** Creates an iterator for all keys. + * + * @return an iterator over all keys. + */ + def keysIterator: Iterator[A] + + /** Creates an iterator for all values in this map. + * + * @return an iterator over all values that are associated with some key in this map. + */ + def valuesIterator: Iterator[B] + + /** Filters this map by retaining only keys satisfying a predicate. + * @param p the predicate used to test keys + * @return an immutable map consisting only of those key value pairs of this map where the key satisfies + * the predicate `p`. The resulting map wraps the original map without copying any elements. + */ + def filterKeys(p: A => Boolean): GenMap[A, B] + + /** Transforms this map by applying a function to every retrieved value. + * @param f the function used to transform values of this map. + * @return a map view which maps every key of this map + * to `f(this(key))`. The resulting map wraps the original map without copying any elements. + */ + def mapValues[C](f: B => C): GenMap[A, C] + /** Compares two maps structurally; i.e. checks if all mappings * contained in this map are also contained in the other map, * and vice versa. |