scala.collection.mutable

trait SynchronizedMap

[source: scala/collection/mutable/SynchronizedMap.scala]

trait SynchronizedMap[A, B]
extends Map[A, B]
This class should be used as a mixin. It synchronizes the Map functions of the class into which it is mixed in.
Author
Matthias Zenger, Martin Odersky
Version
2.0, 31/12/2006
Method Summary
override def + (kv : (A, B)) : SynchronizedMap[A, B]
Add a new key/value mapping and return the map itself.
def += (kv : (A, B)) : SynchronizedMap[A, B]
Add a new key/value mapping this map.
def -= (key : A) : SynchronizedMap[A, B]
Delete a key from this map if it is present.
override def apply (key : A) : B
Retrieve the value which is associated with the given key. This method throws an exception if there is no mapping from the given key to a value.
override def clear : Unit
Removes all elements from the set. After this operation is completed, the set will be empty.
override def clone : Map[A, B]
This method creates and returns a copy of the receiver object.
override def contains (key : A) : Boolean
Is the given key mapped to a value by this map?
override def foreach [U](f : ((A, B)) => U) : Unit
Apply a function f to all elements of this traversable object.
def get (key : A) : Option[B]
Check if this map maps key to a value and return the value as an option if it exists, None if not.
override def getOrElseUpdate (key : A, default : => B) : B
Check if this map maps key to a value. Return that value if it exists, otherwise put default as that key's value and return it.
override def isDefinedAt (key : A) : Boolean
Does this map contain a mapping from the given key to a value?
override def isEmpty : Boolean
Is this an empty map?
def iterator : Iterator[(A, B)]
An iterator yielding all key/value mappings of this map.
override def keySet : Set[A]
override def keys : Iterator[A]
Creates an iterator for all keys.
override def keysIterator : Iterator[A]
Creates an iterator for all keys.
override def put (key : A, value : B) : Option[B]
Adds a new mapping from key to value to the map. If the map already contains a mapping for key, it will be overridden.
override def remove (key : A) : Option[B]
If given key is defined in this map, remove it and return associated value as an Option. If key is not present return None.
override def retain (p : (A, B) => Boolean) : SynchronizedMap[A, B]
Retain only those mappings for which the predicate p returns true.
override def size : Int
The number of elements in this collection
override def transform (f : (A, B) => B) : SynchronizedMap[A, B]
This function transforms all the values of mappings contained in this map with function f.
override def update (key : A, value : B) : Unit
Adds a new mapping from key to value to the map. If the map already contains a mapping for key, it will be overridden.
override def valueIterable : Iterable[B]
override def values : Iterator[B]
Creates an iterator for a contained values.
override def valuesIterator : Iterator[B]
Creates an iterator for a contained values.
Methods inherited from Map
empty
Methods inherited from Unhashable
hashCode, identityHashCode
Methods inherited from MutableMapTemplate
newBuilder, updated, cached, +, ++, ++, -, removeKey, result, -, --, --
Methods inherited from Shrinkable
-=, --=, --=
Methods inherited from Builder
sizeHint, mapResult
Methods inherited from Growable
+=, ++=, ++=
Methods inherited from MutableMapTemplateBase
+
Methods inherited from MapTemplate
getOrElse, default, filterKeys, mapValues, mapElements, +, ++, ++, addString, equals, stringPrefix, toString
Methods inherited from PartialFunction
orElse, andThen
Methods inherited from Function1
compose
Methods inherited from Iterable
companion
Methods inherited from IterableTemplate
elements, foldRight, reduceRight, toIterable, head, takeRight, dropRight, sameElements, toStream, view, view, first, firstOption, toSeq, projection
Methods inherited from TraversableClass
genericBuilder, unzip, flatten, transpose
Methods inherited from TraversableTemplate
thisCollection, nonEmpty, hasDefiniteSize, ++, ++, map, flatMap, filter, filterMap, filterNot, remove, partition, groupBy, forall, exists, count, find, foldLeft, /:, :\, reduceLeft, reduceLeftOption, reduceRightOption, headOption, tail, last, lastOption, init, take, drop, slice, takeWhile, dropWhile, span, splitAt, copyToBuffer, copyToArray, copyToArray, toArray, toList, toSequence, toSet, mkString, mkString, mkString, addString, addString
Methods inherited from AnyRef
getClass, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Method Details
def get(key : A) : Option[B]
Check if this map maps key to a value and return the value as an option if it exists, None if not.
Parameters
key - the key of the mapping of interest.
Returns
the value of the mapping as an option, if it exists, or None.

def iterator : Iterator[(A, B)]
An iterator yielding all key/value mappings of this map.

def +=(kv : (A, B)) : SynchronizedMap[A, B]
Add a new key/value mapping this map.
Parameters
kv - the key/value pair.
Returns
the map itself

def -=(key : A) : SynchronizedMap[A, B]
Delete a key from this map if it is present.
Parameters
key - the key to be removed
Notes
same as `delete`.

override def size : Int
The number of elements in this collection

override def put(key : A, value : B) : Option[B]
Adds a new mapping from key to value to the map. If the map already contains a mapping for key, it will be overridden.
Parameters
key - The key to update
value - The new value

override def update(key : A, value : B) : Unit
Adds a new mapping from key to value to the map. If the map already contains a mapping for key, it will be overridden.
Parameters
key - The key to update
value - The new value
Returns
An option consisting of value associated previously associated with `key` in the map, or None if `key` was not yet defined in the map.

override def remove(key : A) : Option[B]
If given key is defined in this map, remove it and return associated value as an Option. If key is not present return None.
Parameters
key - the key to be removed

override def clear : Unit
Removes all elements from the set. After this operation is completed, the set will be empty.

override def getOrElseUpdate(key : A, default : => B) : B
Check if this map maps key to a value. Return that value if it exists, otherwise put default as that key's value and return it.

override def transform(f : (A, B) => B) : SynchronizedMap[A, B]
This function transforms all the values of mappings contained in this map with function f.
Parameters
f - The transformation to apply

override def retain(p : (A, B) => Boolean) : SynchronizedMap[A, B]
Retain only those mappings for which the predicate p returns true.
Parameters
p - The test predicate

override def valueIterable : Iterable[B]
Returns
the values of this map as an iterable.

@deprecated("Use `valuesIterator' instead")

override def values : Iterator[B]
Creates an iterator for a contained values.
Returns
an iterator over all values.

override def valuesIterator : Iterator[B]
Creates an iterator for a contained values.
Returns
an iterator over all values.

override def clone : Map[A, B]
This method creates and returns a copy of the receiver object.

The default implementation of the clone method is platform dependent.

Returns
a copy of the receiver object.


override def foreach[U](f : ((A, B)) => U) : Unit
Apply a function f to all elements of this traversable object.
Parameters
f - A function that is applied for its side-effect to every element. The result (of arbitrary type U) of function `f` is discarded.
Notes
This method underlies the implementation of most other bulk operations. Implementing `foreach` with `iterator` is often suboptimal. So `foreach` should be overridden in concrete collection classes if a more efficient implementation is available.

override def apply(key : A) : B
Retrieve the value which is associated with the given key. This method throws an exception if there is no mapping from the given key to a value.
Parameters
key - the key
Returns
the value associated with the given key.

override def keySet : Set[A]
Returns
the keys of this map as a set.

@deprecated("Use `keysIterator' instead")

override def keys : Iterator[A]
Creates an iterator for all keys.
Returns
an iterator over all keys.

override def keysIterator : Iterator[A]
Creates an iterator for all keys.
Returns
an iterator over all keys.

override def isEmpty : Boolean
Is this an empty map?
Returns
true iff the map does not contain any key/value mapping.

override def contains(key : A) : Boolean
Is the given key mapped to a value by this map?
Parameters
key - the key
Returns
true iff there is a mapping for key in this map

override def isDefinedAt(key : A) : Boolean
Does this map contain a mapping from the given key to a value?
Parameters
key - the key
Returns
true iff there is a mapping for key in this map

@deprecated

override def +(kv : (A, B)) : SynchronizedMap[A, B]
Add a new key/value mapping and return the map itself.
Parameters
kv - the key/value mapping to be added