scala

class Range

[source: scala/Range.scala]

class Range(val start : Int, val end : Int, val step : Int)
extends BufferedIterator[Int]

The Range class represents integer values in range [start;end) with non-zero step value step. Sort of acts like a sequence also (supports length and contains). For example:

     val r1 = Iterator.range(0, 10)
     val r2 = Iterator.range(r1.start, r1.end, r1.step + 1)
     println(r2.length) // = 5
  
Author
Stephane Micheloud
Version
1.0, 01/05/2007
Method Summary
def apply (idx : Int) : Int
def by (step : Int) : Range
create a new range with the start and end values of this range and a new step
def contains (x : Int) : Boolean
a Seq.contains, not a Iterator.contains!
override def contains (elem : Any) : Boolean
a Iterator.contains, not a Seq.contains!
override def hasNext : Boolean
Does this iterator provide another element?
def length : Int
override def next : Int
Returns the next element.
override def peekList (sz : Int) : Seq[Int]
returns the first sz elements that will be iterated by this iterator, or fewer if the iterator has less elements left to iterate over
def seqOfRange : Projection[Int]
Methods inherited from BufferedIterator
head, peek, defaultPeek, readIf, readWhile, startsWith, buffered, toString
Methods inherited from Iterator
take, drop, map, append, ++, flatMap, filter, takeWhile, dropWhile, zip, zipWithIndex, foreach, forall, exists, find, foldLeft, foldRight, /:, :\, reduceLeft, reduceRight, counted, duplicate, copyToArray, readInto, readInto, readInto, copyToBuffer, toList, mkString, mkString, addString
Methods inherited from AnyRef
getClass, hashCode, equals, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Method Details
def by(step : Int) : Range
create a new range with the start and end values of this range and a new step

override def peekList(sz : Int) : Seq[Int]
returns the first sz elements that will be iterated by this iterator, or fewer if the iterator has less elements left to iterate over
Overrides
BufferedIterator.peekList

override def hasNext : Boolean
Does this iterator provide another element?
Overrides
BufferedIterator.hasNext

override def next : Int
Returns the next element.

def seqOfRange : Projection[Int]

def length : Int

def apply(idx : Int) : Int

def contains(x : Int) : Boolean
a Seq.contains, not a Iterator.contains!

override def contains(elem : Any) : Boolean
a Iterator.contains, not a Seq.contains!