Skip to content

Commit c283e61

Browse files
authored
Merge pull request scala#7161 from xuwei-k/NumericRange-mapRange
remove NumericRange#mapRange
2 parents 065591e + aa0fd0f commit c283e61

File tree

1 file changed

+0
-42
lines changed

1 file changed

+0
-42
lines changed

src/library/scala/collection/immutable/NumericRange.scala

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -145,48 +145,6 @@ sealed class NumericRange[T](
145145
else head
146146
} else super.max(ord)
147147

148-
// Motivated by the desire for Double ranges with BigDecimal precision,
149-
// we need some way to map a Range and get another Range. This can't be
150-
// done in any fully general way because Ranges are not arbitrary
151-
// sequences but step-valued, so we have a custom method only we can call
152-
// which we promise to use responsibly.
153-
//
154-
// The point of it all is that
155-
//
156-
// 0.0 to 1.0 by 0.1
157-
//
158-
// should result in
159-
//
160-
// NumericRange[Double](0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0)
161-
//
162-
// and not
163-
//
164-
// NumericRange[Double](0.0, 0.1, 0.2, 0.30000000000000004, 0.4, 0.5, 0.6000000000000001, 0.7000000000000001, 0.8, 0.9)
165-
//
166-
// or perhaps more importantly,
167-
//
168-
// (0.1 to 0.3 by 0.1 contains 0.3) == true
169-
//
170-
private[immutable] def mapRange[A](fm: T => A)(implicit unum: Integral[A]): NumericRange[A] = {
171-
val self = this
172-
173-
// XXX This may be incomplete.
174-
new NumericRange[A](fm(start), fm(end), fm(step), isInclusive) {
175-
176-
private[this] lazy val underlyingRange: NumericRange[T] = self
177-
override def foreach[@specialized(Unit) U](f: A => U): Unit = { underlyingRange foreach (x => f(fm(x))) }
178-
override def isEmpty = underlyingRange.isEmpty
179-
override def apply(idx: Int): A = fm(underlyingRange(idx))
180-
override def containsTyped(el: A) = underlyingRange exists (x => fm(x) == el)
181-
182-
override def toString = {
183-
def simpleOf(x: Any): String = x.getClass.getName.split("\\.").last
184-
val stepped = simpleOf(underlyingRange.step)
185-
s"${super.toString} (using $underlyingRange of $stepped)"
186-
}
187-
}
188-
}
189-
190148
// a well-typed contains method.
191149
def containsTyped(x: T): Boolean =
192150
isWithinBoundaries(x) && (((x - start) % step) == zero)

0 commit comments

Comments
 (0)