Scala Library
|
|
abstract
class
NumericRange[+T](val
start : T, val
end : T, val
step : T, val
isInclusive : Boolean, implicit
num : Integral[T])
extends
IndexedSeq[T]
NumericRange
is a more generic version of the
Range
class which works with arbitrary types.
It must be supplied with an Integral implementation of the
range type.
Factories for likely types include Range.BigInt, Range.Long,
and Range.BigDecimal. Range.Int exists for completeness, but
the Int-based scala.Range should be more performant.
val r1 = new Range(0, 100, 1) val veryBig = Int.MaxValue.toLong + 1 val r2 = Range.Long(veryBig, veryBig + 100, 1) assert(r1 sameElements r2.map(_ - veryBig))
Value Summary | |
override lazy val
|
hashCode
: Int
Returns a hash code value for the object.
|
Method Summary | |
def
|
apply
(idx : Int) : T
Returns the elements at position `idx`
|
def
|
by
[U >: T](newStep : U)(implicit unum : Integral[U]) : NumericRange[U]
Create a new range with the start and end values of this range and
a new
step . |
override def
|
contains
(x : Any) : Boolean
Tests if the given value
elem is a member of this
sequence. |
def
|
containsTyped
[U >: T](x : U)(implicit unum : Integral[U]) : Boolean
|
abstract def
|
copy
[U >: T](start : U, end : U, step : U)(implicit unum : Integral[U]) : NumericRange[U]
Create a copy of this range.
|
override def
|
equals
(other : Any) : Boolean
The equality method defined in `AnyRef`.
|
override def
|
foreach
[U](f : (T) => U) : Unit
Apply a function
f to all elements of this
iterable object. |
def
|
genericLength : T |
override def
|
isEmpty
: Boolean
Does this iterable contain no elements?
|
def
|
length
: Int
Returns the length of the sequence.
|
protected def
|
limitTest
[U >: T](x : U)(implicit unum : Integral[U]) : Boolean
|
override def
|
toString
: java.lang.String
Need to override string, so that it's not the Function1's string that gets mixed in.
|
protected def
|
underlying : IndexedSeq[T] |
Methods inherited from IndexedSeq | |
companion |
Methods inherited from IndexedSeqLike | |
thisCollection, toCollection, iterator, forall, exists, find, foldLeft, foldRight, reduceLeft, reduceRight, zip, zipWithIndex, slice, head, tail, last, init, take, drop, takeRight, dropRight, splitAt, takeWhile, dropWhile, span, sameElements, copyToArray, lengthCompare, segmentLength, indexWhere, lastIndexWhere, reverse, 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, union, diff, intersect, removeDuplicates, patch, updated, +:, :+, padTo, sortWith, sortWith, sortBy, toSeq, indices, 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 |
override
lazy val
hashCode : Int
The default hashing algorithm is platform dependent.
Note that it is allowed for two objects to have identical hash
codes (o1.hashCode.equals(o2.hashCode)
) yet not be
equal (o1.equals(o2)
returns false
). A
degenerate implementation could always return 0
.
However, it is required that if two objects are equal
(o1.equals(o2)
returns true
) that they
have identical hash codes
(o1.hashCode.equals(o2.hashCode)
). Therefore, when
overriding this method, be sure to verify that the behavior is
consistent with the equals
method.
Method Details |
protected
def
underlying : IndexedSeq[T]
step
.abstract
def
copy[U >: T](start : U, end : U, step : U)(implicit
unum : Integral[U]) : NumericRange[U]
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.
def
genericLength : T
def
length : Int
override
def
isEmpty : Boolean
elem
is a member of this
sequence.elem -
element whose membership has to be tested.true
iff there is an element of this sequence which is equal (w.r.t. ==
) to elem
.override
def
toString : java.lang.String
Scala Library
|
|