@@ -22,13 +22,13 @@ package collection
22
22
* A map is a collection of bindings from keys to values, where there are
23
23
* no duplicate keys.
24
24
*/
25
- trait GenMapLike [A , + B , + Repr ] extends GenIterableLike [(A , B ), Repr ] with Equals with Parallelizable [(A , B ), parallel.ParMap [A , B ]] {
26
- def default (key : A ): B
27
- def get (key : A ): Option [B ]
28
- def apply (key : A ): B
29
- def seq : Map [A , B ]
30
- def + [B1 >: B ](kv : (A , B1 )): GenMap [A , B1 ]
31
- def - (key : A ): Repr
25
+ trait GenMapLike [K , + V , + Repr ] extends GenIterableLike [(K , V ), Repr ] with Equals with Parallelizable [(K , V ), parallel.ParMap [K , V ]] {
26
+ def default (key : K ): V
27
+ def get (key : K ): Option [V ]
28
+ def apply (key : K ): V
29
+ def seq : Map [K , V ]
30
+ def + [V1 >: V ](kv : (K , V1 )): GenMap [K , V1 ]
31
+ def - (key : K ): Repr
32
32
33
33
// This hash code must be symmetric in the contents but ought not
34
34
// collide trivially.
@@ -41,17 +41,17 @@ trait GenMapLike[A, +B, +Repr] extends GenIterableLike[(A, B), Repr] with Equals
41
41
* @tparam B1 the result type of the default computation.
42
42
* @return the value associated with `key` if it exists,
43
43
* otherwise the result of the `default` computation.
44
- * @usecase def getOrElse(key: A , default: => B ): B
44
+ * @usecase def getOrElse(key: K , default: => V ): V
45
45
* @inheritdoc
46
46
*/
47
- def getOrElse [B1 >: B ](key : A , default : => B1 ): B1
47
+ def getOrElse [V1 >: V ](key : K , default : => V1 ): V1
48
48
49
49
/** Tests whether this map contains a binding for a key.
50
50
*
51
51
* @param key the key
52
52
* @return `true` if there is a binding for `key` in this map, `false` otherwise.
53
53
*/
54
- def contains (key : A ): Boolean
54
+ def contains (key : K ): Boolean
55
55
56
56
/** Tests whether this map contains a binding for a key. This method,
57
57
* which implements an abstract method of trait `PartialFunction`,
@@ -60,47 +60,47 @@ trait GenMapLike[A, +B, +Repr] extends GenIterableLike[(A, B), Repr] with Equals
60
60
* @param key the key
61
61
* @return `true` if there is a binding for `key` in this map, `false` otherwise.
62
62
*/
63
- def isDefinedAt (key : A ): Boolean
63
+ def isDefinedAt (key : K ): Boolean
64
64
65
- def keySet : GenSet [A ]
65
+ def keySet : GenSet [K ]
66
66
67
67
/** Collects all keys of this map in an iterable collection.
68
68
*
69
69
* @return the keys of this map as an iterable.
70
70
*/
71
- def keys : GenIterable [A ]
71
+ def keys : GenIterable [K ]
72
72
73
73
/** Collects all values of this map in an iterable collection.
74
74
*
75
75
* @return the values of this map as an iterable.
76
76
*/
77
- def values : GenIterable [B ]
77
+ def values : GenIterable [V ]
78
78
79
79
/** Creates an iterator for all keys.
80
80
*
81
81
* @return an iterator over all keys.
82
82
*/
83
- def keysIterator : Iterator [A ]
83
+ def keysIterator : Iterator [K ]
84
84
85
85
/** Creates an iterator for all values in this map.
86
86
*
87
87
* @return an iterator over all values that are associated with some key in this map.
88
88
*/
89
- def valuesIterator : Iterator [B ]
89
+ def valuesIterator : Iterator [V ]
90
90
91
91
/** Filters this map by retaining only keys satisfying a predicate.
92
92
* @param p the predicate used to test keys
93
93
* @return an immutable map consisting only of those key value pairs of this map where the key satisfies
94
94
* the predicate `p`. The resulting map wraps the original map without copying any elements.
95
95
*/
96
- def filterKeys (p : A => Boolean ): GenMap [A , B ]
96
+ def filterKeys (p : K => Boolean ): GenMap [K , V ]
97
97
98
98
/** Transforms this map by applying a function to every retrieved value.
99
99
* @param f the function used to transform values of this map.
100
100
* @return a map view which maps every key of this map
101
101
* to `f(this(key))`. The resulting map wraps the original map without copying any elements.
102
102
*/
103
- def mapValues [C ](f : B => C ): GenMap [A , C ]
103
+ def mapValues [W ](f : V => W ): GenMap [K , W ]
104
104
105
105
/** Compares two maps structurally; i.e., checks if all mappings
106
106
* contained in this map are also contained in the other map,
0 commit comments