summaryrefslogtreecommitdiff
path: root/src/library/scalax/collection/generic/IterableTemplate.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2009-02-13 11:59:49 +0000
committerMartin Odersky <odersky@gmail.com>2009-02-13 11:59:49 +0000
commit04840e2ed4530df9a5ca59b984bf2b37a976dc70 (patch)
tree61394762e202f8ab60e0d3a8e8ac688404241bc3 /src/library/scalax/collection/generic/IterableTemplate.scala
parent708baf94764e2a839e24ca6204060a8d0664d88c (diff)
downloadscala-04840e2ed4530df9a5ca59b984bf2b37a976dc70.tar.gz
scala-04840e2ed4530df9a5ca59b984bf2b37a976dc70.tar.bz2
scala-04840e2ed4530df9a5ca59b984bf2b37a976dc70.zip
new version of collection libraries
Diffstat (limited to 'src/library/scalax/collection/generic/IterableTemplate.scala')
-rwxr-xr-xsrc/library/scalax/collection/generic/IterableTemplate.scala135
1 files changed, 0 insertions, 135 deletions
diff --git a/src/library/scalax/collection/generic/IterableTemplate.scala b/src/library/scalax/collection/generic/IterableTemplate.scala
index adbf5d2de7..cc562c308a 100755
--- a/src/library/scalax/collection/generic/IterableTemplate.scala
+++ b/src/library/scalax/collection/generic/IterableTemplate.scala
@@ -646,76 +646,6 @@ b * @param thatElem element <code>thatElem</code> is used to fill up the
b.result
}
- /** The last element of this iterable.
- *
- * @throws Predef.NoSuchElementException if the iterable is empty.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def last: A = {
- var lst = head
- for (x <- this)
- lst = x
- lst
- }
-
- /** Returns as an option the last element of this iterable or
- * <code>None</code> if iterable is empty.
- *
- * @return the last element as an option.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def lastOption: Option[A] = if (isEmpty) None else Some(last)
-
- /** An iterable consisting of all elements of this iterable except the last one.
- * @throws Predef.UnsupportedOperationException if the stream is empty.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def init: CC[A] = {
- if (isEmpty) throw new UnsupportedOperationException("empty.init")
- var lst = head
- val b = newBuilder[A]
- for (x <- this) {
- b += lst
- lst = x
- }
- b.result
- }
-
- /** Returns the rightmost <code>n</code> elements from this iterable.
- *
- * @param n the number of elements to take
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def takeRight(n: Int): CC[A] = {
- val b = newBuilder[A]
- val lead = elements drop n
- var go = false
- for (x <- this) {
- if (go) b += x
- else if (lead.hasNext) lead.next
- else go = true
- }
- b.result
- }
-
- /** Returns the iterable wihtout its rightmost <code>n</code> elements.
- *
- * @param n the number of elements to take
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def dropRight(n: Int): CC[A] = {
- val b = newBuilder[A]
- val lead = elements drop n
- breakable {
- for (x <- this) {
- if (!lead.hasNext) break
- lead.next
- b += x
- }
- }
- b.result
- }
-
/** Split the iterable at a given point and return the two parts thus
* created.
*
@@ -732,71 +662,6 @@ b * @param thatElem element <code>thatElem</code> is used to fill up the
(l.result, r.result)
}
- /** Returns the longest prefix of this iterable whose elements satisfy
- * the predicate <code>p</code>.
- *
- * @param p the test predicate.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def takeWhile(p: A => Boolean): CC[A] = {
- val b = newBuilder[A]
- breakable {
- for (x <- this) {
- if (!p(x)) break
- b += x
- }
- }
- b.result
- }
-
- /** Returns the longest suffix of this iterable whose first element
- * does not satisfy the predicate <code>p</code>.
- *
- * @param p the test predicate.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def dropWhile(p: A => Boolean): CC[A] = {
- val b = newBuilder[A]
- var go = false
- for (x <- this) {
- if (go) b += x
- else if (!p(x)) { go = true; b += x }
- }
- b.result
- }
-
- /** Returns a pair consisting of the longest prefix of the iterable whose
- * elements all satisfy the given predicate, and the rest of the iterable.
- *
- * @param p the test predicate
- * @return a pair consisting of the longest prefix of the iterable whose
- * elements all satisfy <code>p</code>, and the rest of the iterable.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def span(p: A => Boolean): (CC[A], CC[A]) = {
- val l, r = newBuilder[A]
- var toLeft = true
- for (x <- this) {
- toLeft = toLeft && p(x)
- (if (toLeft) l else r) += x
- }
- (l.result, r.result)
- }
-
- /** Checks if the other iterable object contains the same elements as this one.
- *
- * @note will not terminate for infinite-sized iterables.
- * @param that the other iterable
- * @return true, iff both iterables contain the same elements.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def sameElements[B >: A](that: OrderedIterable[B]): Boolean = {
- val these = this.elements
- val those = that.elements
- while (these.hasNext && those.hasNext && these.next() == those.next()) {}
- !these.hasNext && !those.hasNext
- }
-
/** A sub-iterable view starting at index `from`
* and extending up to (but not including) index `until`.
*