blob: 6f954d299b4b56a56fd97edb2c37aec55ed2a336 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/* TODO: Reintegrate
* /* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.collection.mutable
/** This class can be used as an adaptor to create mutable maps from
* immutable map implementations. Only method <code>empty</code> has
* to be redefined if the immutable map on which this mutable map is
* originally based is not empty. <code>empty</code> is supposed to
* return the representation of an empty map.
*
* @author Matthias Zenger
* @author Martin Odersky
* @version 2.0, 01/01/2007
*/
@serializable
class ImmutableMapAdaptor[A, B](protected var imap: immutable.Map[A, B])
extends Map[A, B]
{
def size: Int = imap.size
def get(key: A): Option[B] = imap.get(key)
override def isEmpty: Boolean = imap.isEmpty
override def apply(key: A): B = imap.apply(key)
override def contains(key: A): Boolean = imap.contains(key)
override def isDefinedAt(key: A) = imap.isDefinedAt(key)
override def keys: collection.Set[A] = imap.keys
override def keysIterator: Iterator[A] = imap.keysIterator
override def values: collection.Set[A] = imap.values
override def valuesIterator: Iterator[B] = imap.valuesIterator
def iterator: Iterator[(A, B)] = imap.iterator
@deprecated("use `iterator' instead") def elements = iterator
override def toList: List[(A, B)] = imap.toList
def update(key: A, value: B): Unit = { imap = imap.update(key, value) }
def -= (key: A): this.type = { imap = imap - key; this }
override def clear(): Unit = { imap = imap.empty }
override def transform(f: (A, B) => B): Unit = { imap = imap.transform(f) }
override def retain(p: (A, B) => Boolean): Unit = {
imap = imap.filter(xy => p(xy._1, xy._2))
}
override def toString() = imap.toString()
}
*/
|