diff options
author | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2010-04-09 17:41:15 +0000 |
---|---|---|
committer | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2010-04-09 17:41:15 +0000 |
commit | eec07a42845fd2723eee911a4eeaf8a9c0d54044 (patch) | |
tree | 63e6bed235b4d553639410da818c2c29de5a2a44 | |
parent | 1915363914a216462fdf05f43bbea771153eb384 (diff) | |
download | scala-eec07a42845fd2723eee911a4eeaf8a9c0d54044.tar.gz scala-eec07a42845fd2723eee911a4eeaf8a9c0d54044.tar.bz2 scala-eec07a42845fd2723eee911a4eeaf8a9c0d54044.zip |
MultiMap and WeakHashMap docs. no review
-rw-r--r-- | src/library/scala/collection/mutable/MultiMap.scala | 21 | ||||
-rw-r--r-- | src/library/scala/collection/mutable/WeakHashMap.scala | 5 |
2 files changed, 24 insertions, 2 deletions
diff --git a/src/library/scala/collection/mutable/MultiMap.scala b/src/library/scala/collection/mutable/MultiMap.scala index 01ddea070c..fda8524efe 100644 --- a/src/library/scala/collection/mutable/MultiMap.scala +++ b/src/library/scala/collection/mutable/MultiMap.scala @@ -28,6 +28,15 @@ trait MultiMap[A, B] extends Map[A, Set[B]] { @deprecated("use addBinding instead") def add(key: A, value: B): this.type = addBinding(key, value) + /** Assigns the specified `value` to a specified `key`, replacing + * the existing value assigned to that `key` if it is equal to + * the specified value. Otherwise, simply adds another binding to + * the `key`. + * + * @param key The key to which to bind the new value. + * @param value The value to bind to the key. + * @return A reference to this multimap. + */ def addBinding(key: A, value: B): this.type = { get(key) match { case None => @@ -40,6 +49,12 @@ trait MultiMap[A, B] extends Map[A, Set[B]] { this } + /** Removes the binding of `value` to `key` if it exists. + * + * @param key The key of the binding. + * @param value The value to remove. + * @return A reference to this multimap. + */ def removeBinding(key: A, value: B): this.type = { get(key) match { case None => @@ -50,6 +65,12 @@ trait MultiMap[A, B] extends Map[A, Set[B]] { this } + /** Checks if there exists a binding to `key` such that it satisfies the predicate `p`. + * + * @param key The key for which the predicate is checked. + * @param p The predicate which a value assigned to the key must satisfy. + * @return A boolean if such a binding exists + */ def entryExists(key: A, p: B => Boolean): Boolean = get(key) match { case None => false case Some(set) => set exists p diff --git a/src/library/scala/collection/mutable/WeakHashMap.scala b/src/library/scala/collection/mutable/WeakHashMap.scala index cad4dc2e43..8f496add1e 100644 --- a/src/library/scala/collection/mutable/WeakHashMap.scala +++ b/src/library/scala/collection/mutable/WeakHashMap.scala @@ -16,8 +16,9 @@ import JavaConversions._ import generic._ -/** - * @since 2.8 +/** A hash map with weak references to entries which are weakly reachable. + * + * @since 2.8 */ class WeakHashMap[A, B] extends JMapWrapper[A, B](new java.util.WeakHashMap) with JMapWrapperLike[A, B, WeakHashMap[A, B]] { |