diff options
author | James Iry <jamesiry@gmail.com> | 2013-02-11 12:55:06 -0800 |
---|---|---|
committer | James Iry <jamesiry@gmail.com> | 2013-02-13 08:19:41 -0800 |
commit | 62bc99d3b20a7b37a977b19a6202cdac474eb5f6 (patch) | |
tree | 60a21fcd7332f515fa6dcb8c9735208edca828fc /src/library/scala/collection/generic | |
parent | a0b1db4ce72e2f449de9ce2da2b6b0958bc33579 (diff) | |
download | scala-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.scala | 12 |
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 |