diff options
author | Paul Phillips <paulp@improving.org> | 2010-03-15 04:45:47 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-03-15 04:45:47 +0000 |
commit | f972729b04c44c12ea10d5aa5bb841fc3b40ab69 (patch) | |
tree | 3cbbe97f20b10a5303828324be5b0a9ced00df0c /src/library/scala/collection/MapLike.scala | |
parent | 70d4eb9654a2e7a6ba7dad2b62df36793678d99f (diff) | |
download | scala-f972729b04c44c12ea10d5aa5bb841fc3b40ab69.tar.gz scala-f972729b04c44c12ea10d5aa5bb841fc3b40ab69.tar.bz2 scala-f972729b04c44c12ea10d5aa5bb841fc3b40ab69.zip |
Leveraged -Xmigration to burn off some warts wh...
Leveraged -Xmigration to burn off some warts which arose in the new
collections. Warnings put in place for behavioral changes, allowing the
following. 1) Buffers: create new collections on
++ and -- like all the other collections. 2) Maps: eliminated
never-shipped redundant method valuesIterable and supplied these
return types:
def keys: Iterable[A]
def keysIterator: Iterator[A]
def values: Iterable[B]
def valuesIterator: Iterator[B]
def keySet: Set[A]
I concluded that keys should return Iterable because keySet also exists
on Map, and is not solely in the province of Maps even if we wanted to
change it: it's defined on Sorted and also appears in some Sets. So it
seems sensible to have keySet return a Set and keys return the more
general type.
Closes #3089, #3145. Review by odersky.
Diffstat (limited to 'src/library/scala/collection/MapLike.scala')
-rw-r--r-- | src/library/scala/collection/MapLike.scala | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/library/scala/collection/MapLike.scala b/src/library/scala/collection/MapLike.scala index 8806098aa4..ac3c675c14 100644 --- a/src/library/scala/collection/MapLike.scala +++ b/src/library/scala/collection/MapLike.scala @@ -12,6 +12,7 @@ package scala.collection import generic._ import mutable.{Builder, StringBuilder, MapBuilder} +import annotation.migration import PartialFunction._ /** A template trait for maps of type `Map[A, B]` which associate keys of type `A` @@ -181,15 +182,16 @@ self => * * @return an iterator over all keys. */ - @deprecated("use `keysIterator' instead") - def keys: Iterator[A] = keysIterator + @migration(2, 8, "As of 2.8, keys returns Iterable[A] rather than Iterator[A].") + def keys: Iterable[A] = keySet /** Collects all values of this map in an iterable collection. * @return the values of this map as an iterable. */ - def valuesIterable: Iterable[B] = new DefaultValuesIterable + @migration(2, 8, "As of 2.8, values returns Iterable[B] rather than Iterator[B].") + def values: Iterable[B] = new DefaultValuesIterable - /** The implementation class of the iterable returned by `valuesIterable`. + /** The implementation class of the iterable returned by `values`. */ protected class DefaultValuesIterable extends Iterable[B] { def iterator = valuesIterator @@ -207,13 +209,6 @@ self => def next = iter.next._2 } - /** Creates an iterator for all contained values. - * - * @return an iterator over all values. - */ - @deprecated("use `valuesIterator' instead") - def values: Iterator[B] = valuesIterator - /** Defines the default value computation for the map, * returned when a key is not found * The method implemented here throws an exception, |