summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/generic
diff options
context:
space:
mode:
authorJames Iry <jamesiry@gmail.com>2013-02-11 12:55:06 -0800
committerJames Iry <jamesiry@gmail.com>2013-02-13 08:19:41 -0800
commit62bc99d3b20a7b37a977b19a6202cdac474eb5f6 (patch)
tree60a21fcd7332f515fa6dcb8c9735208edca828fc /src/library/scala/collection/generic
parenta0b1db4ce72e2f449de9ce2da2b6b0958bc33579 (diff)
downloadscala-62bc99d3b20a7b37a977b19a6202cdac474eb5f6.tar.gz
scala-62bc99d3b20a7b37a977b19a6202cdac474eb5f6.tar.bz2
scala-62bc99d3b20a7b37a977b19a6202cdac474eb5f6.zip
SI-6642 Adds iteratorFrom, keysIteratorFrom, and valuesIteratorFrom
Adds the ability to efficiently create an iterator that starts at a given key or element of a sorted set or map. Similar work is done for key and value only iterators on maps. The bulk of the work is in RedBlackTree. Most of the rest is pushing the new api methods throughout the appropriate spots in the collection API. This commit leaves undone some similar work possible on mutable TreeSets
Diffstat (limited to 'src/library/scala/collection/generic')
-rw-r--r--src/library/scala/collection/generic/Sorted.scala12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/library/scala/collection/generic/Sorted.scala b/src/library/scala/collection/generic/Sorted.scala
index f962b26bd3..b3847fffc9 100644
--- a/src/library/scala/collection/generic/Sorted.scala
+++ b/src/library/scala/collection/generic/Sorted.scala
@@ -78,6 +78,18 @@ trait Sorted[K, +This <: Sorted[K, This]] {
else
until(next)
}
+
+ /**
+ * Creates an iterator over all the keys(or elements) contained in this
+ * collection greater than or equal to `start`
+ * according to the ordering of this collection. x.keysIteratorFrom(y)
+ * is equivalent to but often more efficient than
+ * x.from(y).keysIterator.
+ *
+ * @param start The lower bound (inclusive)
+ * on the keys to be returned
+ */
+ def keysIteratorFrom(start: K): Iterator[K]
protected def hasAll(j: Iterator[K]): Boolean = {
val i = keySet.iterator