summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/mutable/MultiMap.scala
diff options
context:
space:
mode:
authorAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2010-04-09 17:41:15 +0000
committerAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2010-04-09 17:41:15 +0000
commiteec07a42845fd2723eee911a4eeaf8a9c0d54044 (patch)
tree63e6bed235b4d553639410da818c2c29de5a2a44 /src/library/scala/collection/mutable/MultiMap.scala
parent1915363914a216462fdf05f43bbea771153eb384 (diff)
downloadscala-eec07a42845fd2723eee911a4eeaf8a9c0d54044.tar.gz
scala-eec07a42845fd2723eee911a4eeaf8a9c0d54044.tar.bz2
scala-eec07a42845fd2723eee911a4eeaf8a9c0d54044.zip
MultiMap and WeakHashMap docs. no review
Diffstat (limited to 'src/library/scala/collection/mutable/MultiMap.scala')
-rw-r--r--src/library/scala/collection/mutable/MultiMap.scala21
1 files changed, 21 insertions, 0 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