Scala Library Documentation
|
|
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 = Iterator.range(0, 10) val r2 = Iterator.range(r1.start, r1.end, r1.step + 1) println(r2.length) // = 5
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 ! |
def
|
length
: Int
Returns the length of the sequence.
|
Methods inherited from Projection | |
projection, force, map, append |
Methods inherited from RandomAccessSeq | |
elements, drop, take, slice, reverse, patch, ++, toStream, safeIs |
Methods inherited from Projection | |
flatMap, takeWhile, filter |
Methods inherited from Seq | |
lengthCompare, size, isEmpty, concat, last, lastOption, headOption, isDefinedAt, lastIndexOf, dropWhile, contains, subseq, toArray, equalsWith, startsWith, endsWith, indexOf, containsSlice |
Methods inherited from Collection | |
toString, stringPrefix |
Methods inherited from Iterable | |
partition, foreach, forall, exists, find, findIndexOf, indexOf, foldLeft, foldRight, /:, :\, reduceLeft, reduceRight, copyToBuffer, sameElements, toList, mkString, mkString, mkString, 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 |
Method Details |
step
def
length : Int
Seq.contains
, not a Iterator.contains
!
Scala Library Documentation
|
|