提交 345ff4eb 编写于 作者: P psandoz

8016251: Balanced spliterator for SpinedBuffer

Reviewed-by: mduigou
Contributed-by: NBrian Goetz &lt;brian.goetz@oracle.com&gt;, Peter Levart &lt;peter.levart@gmail.com&gt;, Paul Sandoz <paul.sandoz@oracle.com>
上级 47266178
......@@ -461,7 +461,7 @@ abstract class DoublePipeline<E_IN>
@Override
public final double[] toArray() {
return Nodes.flattenDouble((Node.OfDouble) evaluateToArrayNode(Double[]::new))
.asDoubleArray();
.asPrimitiveArray();
}
//
......
......@@ -498,7 +498,7 @@ abstract class IntPipeline<E_IN>
@Override
public final int[] toArray() {
return Nodes.flattenInt((Node.OfInt) evaluateToArrayNode(Integer[]::new))
.asIntArray();
.asPrimitiveArray();
}
//
......
......@@ -479,7 +479,8 @@ abstract class LongPipeline<E_IN>
@Override
public final long[] toArray() {
return Nodes.flattenLong((Node.OfLong) evaluateToArrayNode(Long[]::new)).asLongArray();
return Nodes.flattenLong((Node.OfLong) evaluateToArrayNode(Long[]::new))
.asPrimitiveArray();
}
......
......@@ -242,7 +242,7 @@ interface Node<T> {
* an instance of an Integer[] array with a length of {@link #count()}
* and then invokes {@link #copyInto(Integer[], int)} with that
* Integer[] array at an offset of 0. This is not efficient and it is
* recommended to invoke {@link #asIntArray()}.
* recommended to invoke {@link #asPrimitiveArray()}.
*/
@Override
default Integer[] asArray(IntFunction<Integer[]> generator) {
......@@ -254,7 +254,7 @@ interface Node<T> {
/**
* {@inheritDoc}
*
* @implSpec the default implementation invokes {@link #asIntArray()} to
* @implSpec the default implementation invokes {@link #asPrimitiveArray()} to
* obtain an int[] array then and copies the elements from that int[]
* array into the boxed Integer[] array. This is not efficient and it
* is recommended to invoke {@link #copyInto(int[], int)}.
......@@ -264,7 +264,7 @@ interface Node<T> {
if (Tripwire.ENABLED)
Tripwire.trip(getClass(), "{0} calling Node.OfInt.copyInto(Integer[], int)");
int[] array = asIntArray();
int[] array = asPrimitiveArray();
for (int i = 0; i < array.length; i++) {
boxed[offset + i] = array[i];
}
......@@ -285,7 +285,7 @@ interface Node<T> {
*
* @return an array containing the contents of this {@code Node}
*/
int[] asIntArray();
int[] asPrimitiveArray();
/**
* Copies the content of this {@code Node} into an int[] array, starting
......@@ -362,7 +362,7 @@ interface Node<T> {
* an instance of a Long[] array with a length of {@link #count()} and
* then invokes {@link #copyInto(Long[], int)} with that Long[] array at
* an offset of 0. This is not efficient and it is recommended to
* invoke {@link #asLongArray()}.
* invoke {@link #asPrimitiveArray()}.
*/
@Override
default Long[] asArray(IntFunction<Long[]> generator) {
......@@ -374,7 +374,7 @@ interface Node<T> {
/**
* {@inheritDoc}
*
* @implSpec the default implementation invokes {@link #asLongArray()}
* @implSpec the default implementation invokes {@link #asPrimitiveArray()}
* to obtain a long[] array then and copies the elements from that
* long[] array into the boxed Long[] array. This is not efficient and
* it is recommended to invoke {@link #copyInto(long[], int)}.
......@@ -384,7 +384,7 @@ interface Node<T> {
if (Tripwire.ENABLED)
Tripwire.trip(getClass(), "{0} calling Node.OfInt.copyInto(Long[], int)");
long[] array = asLongArray();
long[] array = asPrimitiveArray();
for (int i = 0; i < array.length; i++) {
boxed[offset + i] = array[i];
}
......@@ -405,7 +405,7 @@ interface Node<T> {
*
* @return an array containing the contents of this {@code Node}
*/
long[] asLongArray();
long[] asPrimitiveArray();
/**
* Copies the content of this {@code Node} into a long[] array, starting
......@@ -485,7 +485,7 @@ interface Node<T> {
* an instance of a Double[] array with a length of {@link #count()} and
* then invokes {@link #copyInto(Double[], int)} with that Double[]
* array at an offset of 0. This is not efficient and it is recommended
* to invoke {@link #asDoubleArray()}.
* to invoke {@link #asPrimitiveArray()}.
*/
@Override
default Double[] asArray(IntFunction<Double[]> generator) {
......@@ -497,7 +497,7 @@ interface Node<T> {
/**
* {@inheritDoc}
*
* @implSpec the default implementation invokes {@link #asDoubleArray()}
* @implSpec the default implementation invokes {@link #asPrimitiveArray()}
* to obtain a double[] array then and copies the elements from that
* double[] array into the boxed Double[] array. This is not efficient
* and it is recommended to invoke {@link #copyInto(double[], int)}.
......@@ -507,7 +507,7 @@ interface Node<T> {
if (Tripwire.ENABLED)
Tripwire.trip(getClass(), "{0} calling Node.OfDouble.copyInto(Double[], int)");
double[] array = asDoubleArray();
double[] array = asPrimitiveArray();
for (int i = 0; i < array.length; i++) {
boxed[offset + i] = array[i];
}
......@@ -528,7 +528,7 @@ interface Node<T> {
*
* @return an array containing the contents of this {@code Node}
*/
double[] asDoubleArray();
double[] asPrimitiveArray();
/**
* Copies the content of this {@code Node} into a double[] array, starting
......
......@@ -679,7 +679,7 @@ final class Nodes {
}
@Override
public int[] asIntArray() {
public int[] asPrimitiveArray() {
return EMPTY_INT_ARRAY;
}
}
......@@ -696,7 +696,7 @@ final class Nodes {
}
@Override
public long[] asLongArray() {
public long[] asPrimitiveArray() {
return EMPTY_LONG_ARRAY;
}
}
......@@ -713,7 +713,7 @@ final class Nodes {
}
@Override
public double[] asDoubleArray() {
public double[] asPrimitiveArray() {
return EMPTY_DOUBLE_ARRAY;
}
}
......@@ -1395,7 +1395,7 @@ final class Nodes {
}
@Override
public int[] asIntArray() {
public int[] asPrimitiveArray() {
if (array.length == curSize) {
return array;
} else {
......@@ -1449,7 +1449,7 @@ final class Nodes {
}
@Override
public long[] asLongArray() {
public long[] asPrimitiveArray() {
if (array.length == curSize) {
return array;
} else {
......@@ -1503,7 +1503,7 @@ final class Nodes {
}
@Override
public double[] asDoubleArray() {
public double[] asPrimitiveArray() {
if (array.length == curSize) {
return array;
} else {
......@@ -1561,7 +1561,7 @@ final class Nodes {
}
@Override
public int[] asIntArray() {
public int[] asPrimitiveArray() {
int[] array = new int[(int) count()];
copyInto(array, 0);
return array;
......@@ -1594,7 +1594,7 @@ final class Nodes {
}
@Override
public long[] asLongArray() {
public long[] asPrimitiveArray() {
long[] array = new long[(int) count()];
copyInto(array, 0);
return array;
......@@ -1627,7 +1627,7 @@ final class Nodes {
}
@Override
public double[] asDoubleArray() {
public double[] asPrimitiveArray() {
double[] array = new double[(int) count()];
copyInto(array, 0);
return array;
......@@ -1844,9 +1844,9 @@ final class Nodes {
}
@Override
public int[] asIntArray() {
public int[] asPrimitiveArray() {
assert !building : "during building";
return super.asIntArray();
return super.asPrimitiveArray();
}
@Override
......@@ -1904,9 +1904,9 @@ final class Nodes {
}
@Override
public long[] asLongArray() {
public long[] asPrimitiveArray() {
assert !building : "during building";
return super.asLongArray();
return super.asPrimitiveArray();
}
@Override
......@@ -1964,9 +1964,9 @@ final class Nodes {
}
@Override
public double[] asDoubleArray() {
public double[] asPrimitiveArray() {
assert !building : "during building";
return super.asDoubleArray();
return super.asPrimitiveArray();
}
@Override
......
......@@ -192,7 +192,7 @@ final class SortedOps {
else {
Node.OfInt n = (Node.OfInt) helper.evaluate(spliterator, true, generator);
int[] content = n.asIntArray();
int[] content = n.asPrimitiveArray();
Arrays.parallelSort(content);
return Nodes.node(content);
......@@ -231,7 +231,7 @@ final class SortedOps {
else {
Node.OfLong n = (Node.OfLong) helper.evaluate(spliterator, true, generator);
long[] content = n.asLongArray();
long[] content = n.asPrimitiveArray();
Arrays.parallelSort(content);
return Nodes.node(content);
......@@ -270,7 +270,7 @@ final class SortedOps {
else {
Node.OfDouble n = (Node.OfDouble) helper.evaluate(spliterator, true, generator);
double[] content = n.asDoubleArray();
double[] content = n.asPrimitiveArray();
Arrays.parallelSort(content);
return Nodes.node(content);
......@@ -401,7 +401,7 @@ final class SortedOps {
@Override
public void end() {
int[] ints = b.asIntArray();
int[] ints = b.asPrimitiveArray();
Arrays.sort(ints);
downstream.begin(ints.length);
for (int anInt : ints)
......@@ -466,7 +466,7 @@ final class SortedOps {
@Override
public void end() {
long[] longs = b.asLongArray();
long[] longs = b.asPrimitiveArray();
Arrays.sort(longs);
downstream.begin(longs.length);
for (long aLong : longs)
......@@ -531,7 +531,7 @@ final class SortedOps {
@Override
public void end() {
double[] doubles = b.asDoubleArray();
double[] doubles = b.asPrimitiveArray();
Arrays.sort(doubles);
downstream.begin(doubles.length);
for (double aDouble : doubles)
......
......@@ -122,12 +122,12 @@ public class DoubleNodeTest extends OpTestCase {
@Test(dataProvider = "nodes")
public void testAsArray(double[] array, Node.OfDouble n) {
assertEquals(n.asDoubleArray(), array);
assertEquals(n.asPrimitiveArray(), array);
}
@Test(dataProvider = "nodes")
public void testFlattenAsArray(double[] array, Node.OfDouble n) {
assertEquals(Nodes.flattenDouble(n).asDoubleArray(), array);
assertEquals(Nodes.flattenDouble(n).asPrimitiveArray(), array);
}
@Test(dataProvider = "nodes")
......
......@@ -122,12 +122,12 @@ public class IntNodeTest extends OpTestCase {
@Test(dataProvider = "nodes")
public void testAsArray(int[] array, Node.OfInt n) {
assertEquals(n.asIntArray(), array);
assertEquals(n.asPrimitiveArray(), array);
}
@Test(dataProvider = "nodes")
public void testFlattenAsArray(int[] array, Node.OfInt n) {
assertEquals(Nodes.flattenInt(n).asIntArray(), array);
assertEquals(Nodes.flattenInt(n).asPrimitiveArray(), array);
}
@Test(dataProvider = "nodes")
......
......@@ -122,12 +122,12 @@ public class LongNodeTest extends OpTestCase {
@Test(dataProvider = "nodes")
public void testAsArray(long[] array, Node.OfLong n) {
assertEquals(n.asLongArray(), array);
assertEquals(n.asPrimitiveArray(), array);
}
@Test(dataProvider = "nodes")
public void testFlattenAsArray(long[] array, Node.OfLong n) {
assertEquals(Nodes.flattenLong(n).asLongArray(), array);
assertEquals(Nodes.flattenLong(n).asPrimitiveArray(), array);
}
@Test(dataProvider = "nodes")
......
......@@ -210,7 +210,7 @@ public class SpinedBufferTest {
list2.clear();
sb.forEach((int i) -> list2.add(i));
assertEquals(list1, list2);
int[] array = sb.asIntArray();
int[] array = sb.asPrimitiveArray();
list2.clear();
for (int i : array)
list2.add(i);
......@@ -285,7 +285,7 @@ public class SpinedBufferTest {
list2.clear();
sb.forEach((long i) -> list2.add(i));
assertEquals(list1, list2);
long[] array = sb.asLongArray();
long[] array = sb.asPrimitiveArray();
list2.clear();
for (long i : array)
list2.add(i);
......@@ -361,7 +361,7 @@ public class SpinedBufferTest {
list2.clear();
sb.forEach((double i) -> list2.add(i));
assertEquals(list1, list2);
double[] array = sb.asDoubleArray();
double[] array = sb.asPrimitiveArray();
list2.clear();
for (double i : array)
list2.add(i);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册