summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/immutable/ListMap.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/library/scala/collection/immutable/ListMap.scala')
-rw-r--r--src/library/scala/collection/immutable/ListMap.scala15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/library/scala/collection/immutable/ListMap.scala b/src/library/scala/collection/immutable/ListMap.scala
index 782d471aa4..1705378846 100644
--- a/src/library/scala/collection/immutable/ListMap.scala
+++ b/src/library/scala/collection/immutable/ListMap.scala
@@ -79,13 +79,14 @@ class ListMap[A, +B] extends Map[A, B] {
/** Returns an iterator over key-value pairs.
*/
- def elements: Iterator[Pair[A,B]] = new Iterator[Pair[A,B]] {
- var self: ListMap[A,B] = ListMap.this
- def hasNext = !self.isEmpty
- def next: Pair[A,B] =
- if (!hasNext) throw new NoSuchElementException("next on empty iterator")
- else { val res = Pair(self.key, self.value); self = self.next; res }
- }
+ def elements: Iterator[Pair[A,B]] =
+ new Iterator[Pair[A,B]] {
+ var self: ListMap[A,B] = ListMap.this
+ def hasNext = !self.isEmpty
+ def next: Pair[A,B] =
+ if (!hasNext) throw new NoSuchElementException("next on empty iterator")
+ else { val res = Pair(self.key, self.value); self = self.next; res }
+ }.toList.reverse.elements
protected def key: A = throw new NoSuchElementException("empty map")
protected def value: B = throw new NoSuchElementException("empty map")