|
Scala Library
|
|
scala/Range.scala]
class
Range(val start : Int, val end : Int, val step : Int)
extends Projection[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 = 0 until 10
val r2 = r1.start until r1.end by r1.step + 1
println(r2.length) // = 5
| Value Summary | |
lazy val
|
length
: Int
Returns the length of the sequence.
|
| 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
|
foreach
(f : (Int) => Unit) : Unit
Apply a function
f to all elements of this
iterable object. |
protected def
|
inInterval
(x : Int) : Boolean
Is the argument inside the interval defined by `start' and `end'?
Returns true if `x' is inside [start, end).
|
def
|
inclusive : Inclusive |
protected def
|
last (base : Int, step : Int) : Int |
| Methods inherited from Projection | |
| projection, force, map, append |
| Methods inherited from RandomAccessSeq | |
| elements, drop, take, slice, reverse, partition, patch, ++, toStream, safeIs |
| Methods inherited from Projection | |
| flatMap, takeWhile, filter |
| Methods inherited from Seq | |
| lengthCompare, size, isEmpty, concat, last, lastOption, first, firstOption, headOption, isDefinedAt, lastIndexOf, findIndexOf, indexOf, slice, dropWhile, contains, subseq, toArray, toSeq, equalsWith, startsWith, startsWith, endsWith, indexOf, containsSlice |
| Methods inherited from Collection | |
| toString, stringPrefix |
| Methods inherited from Iterable | |
| forall, exists, find, foldLeft, foldRight, /:, :\, reduceLeft, reduceRight, copyToBuffer, sameElements, toList, mkString, mkString, mkString, addString, addString, addString, copyToArray, hasDefiniteSize |
| Methods inherited from PartialFunction | |
| orElse, andThen |
| Methods inherited from Function1 | |
| compose |
| Methods inherited from AnyRef | |
| getClass, hashCode, equals, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized |
| Methods inherited from Any | |
| ==, !=, isInstanceOf, asInstanceOf |
| Value Details |
| Method Details |
step.f to all elements of this
iterable object.f - a function that is applied to every element.Seq.contains, not a Iterator.contains!
def
inclusive : Inclusive
|
Scala Library
|
|