aboutsummaryrefslogtreecommitdiff
path: root/src/share/classes/java/util/stream
diff options
context:
space:
mode:
authorpsandoz <none@none>2013-06-10 11:52:32 +0200
committerpsandoz <none@none>2013-06-10 11:52:32 +0200
commit4c998b5d21b86856dc356b10a0f7ec0b7e98ea6b (patch)
tree1883072fdf50a61825246f562d7c57c351b68c64 /src/share/classes/java/util/stream
parent7c4e92fcaf29f12d4cc0335e838a834e87014fb6 (diff)
downloadjdk8u_jdk-4c998b5d21b86856dc356b10a0f7ec0b7e98ea6b.tar.gz
8015492: Remove DoubleStream.range methods
Reviewed-by: alanb
Diffstat (limited to 'src/share/classes/java/util/stream')
-rw-r--r--src/share/classes/java/util/stream/DoubleStream.java71
-rw-r--r--src/share/classes/java/util/stream/Streams.java81
2 files changed, 0 insertions, 152 deletions
diff --git a/src/share/classes/java/util/stream/DoubleStream.java b/src/share/classes/java/util/stream/DoubleStream.java
index f402b5daee..1706c31572 100644
--- a/src/share/classes/java/util/stream/DoubleStream.java
+++ b/src/share/classes/java/util/stream/DoubleStream.java
@@ -753,75 +753,4 @@ public interface DoubleStream extends BaseStream<Double, DoubleStream> {
},
Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL));
}
-
- /**
- * Returns a sequential {@code DoubleStream} from {@code startInclusive} (inclusive)
- * to {@code endExclusive} (exclusive) by an incremental step of 1.0.
- *
- * @implSpec
- * The implementation behaves as if:
- * <pre>{@code
- * doubleRange(startInclusive, endExclusive, 1.0);
- * }</pre>
- *
- * @param startInclusive the (inclusive) initial value
- * @param endExclusive the exclusive upper bound
- * @return a sequential {@code DoubleStream} for the range of {@code double}
- * elements
- */
- public static DoubleStream range(double startInclusive, double endExclusive) {
- return range(startInclusive, endExclusive, 1.0);
- }
-
- /**
- * Returns a sequential {@code DoubleStream} from {@code startInclusive}
- * (inclusive) to {@code endExclusive} (exclusive) by {@code step}. If
- * {@code startInclusive} is greater than or equal to {@code
- * endExclusive}, an empty stream is returned.
- *
- * An equivalent sequence of increasing values can be produced
- * sequentially using a {@code for} loop as follows:
- * <pre>{@code
- * long size = (long) Math.ceil((startInclusive - endExclusive) / step);
- * long i = 0
- * for (double v = startInclusive; i < size; i++, v = startInclusive + step * i) {
- * ...
- * }
- * }</pre>
- *
- * @param startInclusive the (inclusive) initial value
- * @param endExclusive the exclusive upper bound
- * @param step the difference between consecutive values
- * @return a sequential {@code DoubleStream} for tne range of {@code double}
- * elements
- * @throws IllegalArgumentException if {@code step} is less than or equal to
- * 0. is {@code NaN}, or the count of elements in the range would be
- * greater than {@code Long.MAX_VALUE}
- */
- public static DoubleStream range(double startInclusive, double endExclusive, double step) {
- // @@@ Need to check for ranges that may not produce distinct values
- // such as when the step is very small
- // Also clarify the size of the range which may produce more or less
- // than expected
- if (step <= 0 || Double.isNaN(step)) {
- throw new IllegalArgumentException(String.format("Illegal step: %f", step));
- } else {
- double range = endExclusive - startInclusive;
- if (range <= 0) {
- return empty();
- }
- double size = Math.ceil((endExclusive - startInclusive) / step);
- if (Double.isNaN(size)) {
- throw new IllegalArgumentException(
- String.format("Illegal range: %f size is NaN", size));
- } else if (size > Long.MAX_VALUE) {
- throw new IllegalArgumentException(
- String.format("Illegal range: size %f > Long.MAX_VALUE", size));
- } else {
- return StreamSupport.doubleStream(
- new Streams.RangeDoubleSpliterator(
- startInclusive, endExclusive, step, 0, (long) size));
- }
- }
- }
}
diff --git a/src/share/classes/java/util/stream/Streams.java b/src/share/classes/java/util/stream/Streams.java
index 9693839de6..22b973f742 100644
--- a/src/share/classes/java/util/stream/Streams.java
+++ b/src/share/classes/java/util/stream/Streams.java
@@ -192,87 +192,6 @@ class Streams {
}
}
- /**
- * A {@code double} range spliterator.
- *
- * <p>The traversing and splitting logic is equivalent to that of
- * {@code RangeLongSpliterator} for increasing values with a {@code step} of
- * {@code 1}.
- *
- * <p>A {@code double} value is calculated from the function
- * {@code start + i * step} where {@code i} is the absolute position of the
- * value when traversing an instance of this class that has not been split.
- * This ensures the same values are produced at the same absolute positions
- * regardless of how an instance of this class is split or traversed.
- */
- static final class RangeDoubleSpliterator implements Spliterator.OfDouble {
- private final double from;
- private final double upTo;
- private final double step;
-
- private long lFrom;
- private final long lUpTo;
-
- RangeDoubleSpliterator(double from, double upTo, double step, long lFrom, long lUpTo) {
- this.from = from;
- this.upTo = upTo;
- this.step = step;
- this.lFrom = lFrom;
- this.lUpTo = lUpTo;
- }
-
- @Override
- public boolean tryAdvance(DoubleConsumer consumer) {
- boolean hasNext = lFrom < lUpTo;
- if (hasNext) {
- consumer.accept(from + lFrom * step);
- lFrom++;
- }
- return hasNext;
- }
-
- @Override
- public void forEachRemaining(DoubleConsumer consumer) {
- double hOrigin = from;
- double hStep = step;
- long hLUpTo = lUpTo;
- long i = lFrom;
- for (; i < hLUpTo; i++) {
- consumer.accept(hOrigin + i * hStep);
- }
- lFrom = i;
- }
-
- @Override
- public long estimateSize() {
- return lUpTo - lFrom;
- }
-
- @Override
- public int characteristics() {
- return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED |
- Spliterator.IMMUTABLE | Spliterator.NONNULL |
- Spliterator.DISTINCT | Spliterator.SORTED;
- }
-
- @Override
- public Comparator<? super Double> getComparator() {
- return null;
- }
-
- @Override
- public Spliterator.OfDouble trySplit() {
- return estimateSize() <= 1
- ? null
- : new RangeDoubleSpliterator(from, upTo, step, lFrom, lFrom = lFrom + midPoint());
- }
-
- private long midPoint() {
- // Size is known to be >= 2
- return (lUpTo - lFrom) / 2;
- }
- }
-
private static abstract class AbstractStreamBuilderImpl<T, S extends Spliterator<T>> implements Spliterator<T> {
// >= 0 when building, < 0 when built
// -1 == no elements