|
Scala Library
|
|
scala/collection/immutable/Range.scala]
class
Range(val start : Int, val end : Int, val step : Int)
extends IndexedSeq[Int]
The Range class represents integer values in range
[start;end) with non-zero step value step.
It's a special case of an indexed sequence.
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 | |
final def
|
apply
(idx : Int) : Int
Returns the elements at position `idx`
|
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 |
protected def
|
copy (start : Int, end : Int, step : Int) : Range |
override final def
|
drop
(n : Int) : Range
Returns this traversable without its
n first elements
If this traversable has less than n elements, the empty
traversable is returned. |
override final def
|
dropRight
(n : Int) : Range
Returns the iterable wihtout its rightmost
n elements. |
override final def
|
dropWhile
(p : (Int) => Boolean) : Range
Returns the longest suffix of this traversable whose first element
does not satisfy the predicate
p. |
override def
|
equals
(other : Any) : Boolean
The equality method defined in `AnyRef`.
|
override def
|
foreach
[U](f : (Int) => U) : Unit
Apply a function
f to all elements of this
iterable object. |
def
|
inclusive
: Inclusive
Make range inclusive.
|
override final def
|
init
: Range
a traversable consisting of all elements of this traversable except the last one.
|
override final def
|
isEmpty
: Boolean
Does this iterable contain no elements?
|
def
|
isInclusive : Boolean |
protected def
|
limit : Int |
override final def
|
reverse
: Range
A sequence of type
C consisting of all elements of
this sequence in reverse order. |
override final def
|
slice
(from : Int, until : Int) : Range
A sub-iterable starting at index `from`
and extending up to (but not including) index `until`.
|
override final def
|
span
(p : (Int) => Boolean) : (Range, Range)
Returns a pair consisting of the longest prefix of the traversable whose
elements all satisfy the given predicate, and the rest of the traversable.
|
override final def
|
splitAt
(n : Int) : (Range, Range)
Split the traversable at a given point and return the two parts thus
created.
|
override final def
|
take
(n : Int) : Range
Return an iterable consisting only of the first
n
elements of this iterable, or else the whole iterable, if it has less
than n elements. |
override final def
|
takeRight
(n : Int) : Range
Returns the rightmost
n elements from this iterable. |
override final def
|
takeWhile
(p : (Int) => Boolean) : Range
Returns the longest prefix of this iterable whose elements satisfy
the predicate
p. |
override def
|
toString
: java.lang.String
Need to override string, so that it's not the Function1's string that gets mixed in.
|
| Methods inherited from IndexedSeq | |
| companion |
| Methods inherited from IndexedSeqLike | |
| thisCollection, toCollection, iterator, forall, exists, find, foldLeft, foldRight, reduceLeft, reduceRight, zip, zipWithIndex, head, tail, last, sameElements, copyToArray, lengthCompare, segmentLength, indexWhere, lastIndexWhere, reverseIterator, startsWith, endsWith, view, view |
| Methods inherited from SeqLike | |
| size, isDefinedAt, prefixLength, indexWhere, findIndexOf, indexOf, indexOf, lastIndexOf, lastIndexOf, lastIndexWhere, reverseMap, reversedElements, startsWith, indexOfSeq, indexOfSeq, lastIndexOfSeq, lastIndexOfSeq, contains, union, diff, intersect, removeDuplicates, patch, updated, +:, :+, padTo, sortWith, sortWith, sortBy, toSeq, indices, hashCode, findLastIndexOf, equalsWith, containsSlice, projection |
| Methods inherited from PartialFunction | |
| orElse, andThen |
| Methods inherited from Function1 | |
| compose |
| Methods inherited from IterableLike | |
| elements, toIterable, zipAll, toStream, canEqual, first, firstOption |
| Methods inherited from GenericTraversableTemplate | |
| newBuilder, genericBuilder, unzip, flatten, transpose |
| Methods inherited from TraversableLike | |
| repr, nonEmpty, hasDefiniteSize, ++, ++, map, flatMap, filter, filterNot, partialMap, remove, partition, groupBy, count, /:, :\, reduceLeftOption, reduceRightOption, sum, product, min, max, headOption, lastOption, copyToBuffer, copyToArray, toArray, toList, toIndexedSeq, toSet, mkString, mkString, mkString, addString, addString, addString, stringPrefix, withFilter |
| Methods inherited from AnyRef | |
| getClass, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized |
| Methods inherited from Any | |
| ==, !=, isInstanceOf, asInstanceOf |
| Value Details |
| Method Details |
step.
def
isInclusive : Boolean
protected
def
limit : Int
f to all elements of this
iterable object.f - A function that is applied for its side-effect to every element. The result (of arbitrary type U) of function `f` is discarded.override final
def
isEmpty : Boolean
n
elements of this iterable, or else the whole iterable, if it has less
than n elements.n - the number of elements to taken first elements
If this traversable has less than n elements, the empty
traversable is returned.n - the number of elements to dropoverride final
def
init : Range
from - The index of the first element of the returned subsequenceuntil - The index of the element following the returned subsequencep.p - the test predicate.p.p - the test predicate.p - the test predicatep, and the rest of the traversable.n - the position at which to splitn elements, and the other elements.n elements from this iterable.n - the number of elements to taken elements.n - the number of elements to takeoverride final
def
reverse : Range
C consisting of all elements of
this sequence in reverse order.
def
inclusive : Inclusive
override
def
toString : java.lang.String
|
Scala Library
|
|