equal
deleted
inserted
replaced
240 * |
240 * |
241 * @implSpec the default implementation invokes the generator to create |
241 * @implSpec the default implementation invokes the generator to create |
242 * an instance of an Integer[] array with a length of {@link #count()} |
242 * an instance of an Integer[] array with a length of {@link #count()} |
243 * and then invokes {@link #copyInto(Integer[], int)} with that |
243 * and then invokes {@link #copyInto(Integer[], int)} with that |
244 * Integer[] array at an offset of 0. This is not efficient and it is |
244 * Integer[] array at an offset of 0. This is not efficient and it is |
245 * recommended to invoke {@link #asIntArray()}. |
245 * recommended to invoke {@link #asPrimitiveArray()}. |
246 */ |
246 */ |
247 @Override |
247 @Override |
248 default Integer[] asArray(IntFunction<Integer[]> generator) { |
248 default Integer[] asArray(IntFunction<Integer[]> generator) { |
249 Integer[] boxed = generator.apply((int) count()); |
249 Integer[] boxed = generator.apply((int) count()); |
250 copyInto(boxed, 0); |
250 copyInto(boxed, 0); |
252 } |
252 } |
253 |
253 |
254 /** |
254 /** |
255 * {@inheritDoc} |
255 * {@inheritDoc} |
256 * |
256 * |
257 * @implSpec the default implementation invokes {@link #asIntArray()} to |
257 * @implSpec the default implementation invokes {@link #asPrimitiveArray()} to |
258 * obtain an int[] array then and copies the elements from that int[] |
258 * obtain an int[] array then and copies the elements from that int[] |
259 * array into the boxed Integer[] array. This is not efficient and it |
259 * array into the boxed Integer[] array. This is not efficient and it |
260 * is recommended to invoke {@link #copyInto(int[], int)}. |
260 * is recommended to invoke {@link #copyInto(int[], int)}. |
261 */ |
261 */ |
262 @Override |
262 @Override |
263 default void copyInto(Integer[] boxed, int offset) { |
263 default void copyInto(Integer[] boxed, int offset) { |
264 if (Tripwire.ENABLED) |
264 if (Tripwire.ENABLED) |
265 Tripwire.trip(getClass(), "{0} calling Node.OfInt.copyInto(Integer[], int)"); |
265 Tripwire.trip(getClass(), "{0} calling Node.OfInt.copyInto(Integer[], int)"); |
266 |
266 |
267 int[] array = asIntArray(); |
267 int[] array = asPrimitiveArray(); |
268 for (int i = 0; i < array.length; i++) { |
268 for (int i = 0; i < array.length; i++) { |
269 boxed[offset + i] = array[i]; |
269 boxed[offset + i] = array[i]; |
270 } |
270 } |
271 } |
271 } |
272 |
272 |
283 * responsibility to decide if either this node or the array is utilized |
283 * responsibility to decide if either this node or the array is utilized |
284 * as the primary reference for the data.</p> |
284 * as the primary reference for the data.</p> |
285 * |
285 * |
286 * @return an array containing the contents of this {@code Node} |
286 * @return an array containing the contents of this {@code Node} |
287 */ |
287 */ |
288 int[] asIntArray(); |
288 int[] asPrimitiveArray(); |
289 |
289 |
290 /** |
290 /** |
291 * Copies the content of this {@code Node} into an int[] array, starting |
291 * Copies the content of this {@code Node} into an int[] array, starting |
292 * at a given offset into the array. It is the caller's responsibility |
292 * at a given offset into the array. It is the caller's responsibility |
293 * to ensure there is sufficient room in the array. |
293 * to ensure there is sufficient room in the array. |
360 * |
360 * |
361 * @implSpec the default implementation invokes the generator to create |
361 * @implSpec the default implementation invokes the generator to create |
362 * an instance of a Long[] array with a length of {@link #count()} and |
362 * an instance of a Long[] array with a length of {@link #count()} and |
363 * then invokes {@link #copyInto(Long[], int)} with that Long[] array at |
363 * then invokes {@link #copyInto(Long[], int)} with that Long[] array at |
364 * an offset of 0. This is not efficient and it is recommended to |
364 * an offset of 0. This is not efficient and it is recommended to |
365 * invoke {@link #asLongArray()}. |
365 * invoke {@link #asPrimitiveArray()}. |
366 */ |
366 */ |
367 @Override |
367 @Override |
368 default Long[] asArray(IntFunction<Long[]> generator) { |
368 default Long[] asArray(IntFunction<Long[]> generator) { |
369 Long[] boxed = generator.apply((int) count()); |
369 Long[] boxed = generator.apply((int) count()); |
370 copyInto(boxed, 0); |
370 copyInto(boxed, 0); |
372 } |
372 } |
373 |
373 |
374 /** |
374 /** |
375 * {@inheritDoc} |
375 * {@inheritDoc} |
376 * |
376 * |
377 * @implSpec the default implementation invokes {@link #asLongArray()} |
377 * @implSpec the default implementation invokes {@link #asPrimitiveArray()} |
378 * to obtain a long[] array then and copies the elements from that |
378 * to obtain a long[] array then and copies the elements from that |
379 * long[] array into the boxed Long[] array. This is not efficient and |
379 * long[] array into the boxed Long[] array. This is not efficient and |
380 * it is recommended to invoke {@link #copyInto(long[], int)}. |
380 * it is recommended to invoke {@link #copyInto(long[], int)}. |
381 */ |
381 */ |
382 @Override |
382 @Override |
383 default void copyInto(Long[] boxed, int offset) { |
383 default void copyInto(Long[] boxed, int offset) { |
384 if (Tripwire.ENABLED) |
384 if (Tripwire.ENABLED) |
385 Tripwire.trip(getClass(), "{0} calling Node.OfInt.copyInto(Long[], int)"); |
385 Tripwire.trip(getClass(), "{0} calling Node.OfInt.copyInto(Long[], int)"); |
386 |
386 |
387 long[] array = asLongArray(); |
387 long[] array = asPrimitiveArray(); |
388 for (int i = 0; i < array.length; i++) { |
388 for (int i = 0; i < array.length; i++) { |
389 boxed[offset + i] = array[i]; |
389 boxed[offset + i] = array[i]; |
390 } |
390 } |
391 } |
391 } |
392 |
392 |
403 * responsibility to decide if either this node or the array is utilized |
403 * responsibility to decide if either this node or the array is utilized |
404 * as the primary reference for the data. |
404 * as the primary reference for the data. |
405 * |
405 * |
406 * @return an array containing the contents of this {@code Node} |
406 * @return an array containing the contents of this {@code Node} |
407 */ |
407 */ |
408 long[] asLongArray(); |
408 long[] asPrimitiveArray(); |
409 |
409 |
410 /** |
410 /** |
411 * Copies the content of this {@code Node} into a long[] array, starting |
411 * Copies the content of this {@code Node} into a long[] array, starting |
412 * at a given offset into the array. It is the caller's responsibility |
412 * at a given offset into the array. It is the caller's responsibility |
413 * to ensure there is sufficient room in the array. |
413 * to ensure there is sufficient room in the array. |
483 * |
483 * |
484 * @implSpec the default implementation invokes the generator to create |
484 * @implSpec the default implementation invokes the generator to create |
485 * an instance of a Double[] array with a length of {@link #count()} and |
485 * an instance of a Double[] array with a length of {@link #count()} and |
486 * then invokes {@link #copyInto(Double[], int)} with that Double[] |
486 * then invokes {@link #copyInto(Double[], int)} with that Double[] |
487 * array at an offset of 0. This is not efficient and it is recommended |
487 * array at an offset of 0. This is not efficient and it is recommended |
488 * to invoke {@link #asDoubleArray()}. |
488 * to invoke {@link #asPrimitiveArray()}. |
489 */ |
489 */ |
490 @Override |
490 @Override |
491 default Double[] asArray(IntFunction<Double[]> generator) { |
491 default Double[] asArray(IntFunction<Double[]> generator) { |
492 Double[] boxed = generator.apply((int) count()); |
492 Double[] boxed = generator.apply((int) count()); |
493 copyInto(boxed, 0); |
493 copyInto(boxed, 0); |
495 } |
495 } |
496 |
496 |
497 /** |
497 /** |
498 * {@inheritDoc} |
498 * {@inheritDoc} |
499 * |
499 * |
500 * @implSpec the default implementation invokes {@link #asDoubleArray()} |
500 * @implSpec the default implementation invokes {@link #asPrimitiveArray()} |
501 * to obtain a double[] array then and copies the elements from that |
501 * to obtain a double[] array then and copies the elements from that |
502 * double[] array into the boxed Double[] array. This is not efficient |
502 * double[] array into the boxed Double[] array. This is not efficient |
503 * and it is recommended to invoke {@link #copyInto(double[], int)}. |
503 * and it is recommended to invoke {@link #copyInto(double[], int)}. |
504 */ |
504 */ |
505 @Override |
505 @Override |
506 default void copyInto(Double[] boxed, int offset) { |
506 default void copyInto(Double[] boxed, int offset) { |
507 if (Tripwire.ENABLED) |
507 if (Tripwire.ENABLED) |
508 Tripwire.trip(getClass(), "{0} calling Node.OfDouble.copyInto(Double[], int)"); |
508 Tripwire.trip(getClass(), "{0} calling Node.OfDouble.copyInto(Double[], int)"); |
509 |
509 |
510 double[] array = asDoubleArray(); |
510 double[] array = asPrimitiveArray(); |
511 for (int i = 0; i < array.length; i++) { |
511 for (int i = 0; i < array.length; i++) { |
512 boxed[offset + i] = array[i]; |
512 boxed[offset + i] = array[i]; |
513 } |
513 } |
514 } |
514 } |
515 |
515 |
526 * responsibility to decide if either this node or the array is utilized |
526 * responsibility to decide if either this node or the array is utilized |
527 * as the primary reference for the data. |
527 * as the primary reference for the data. |
528 * |
528 * |
529 * @return an array containing the contents of this {@code Node} |
529 * @return an array containing the contents of this {@code Node} |
530 */ |
530 */ |
531 double[] asDoubleArray(); |
531 double[] asPrimitiveArray(); |
532 |
532 |
533 /** |
533 /** |
534 * Copies the content of this {@code Node} into a double[] array, starting |
534 * Copies the content of this {@code Node} into a double[] array, starting |
535 * at a given offset into the array. It is the caller's responsibility |
535 * at a given offset into the array. It is the caller's responsibility |
536 * to ensure there is sufficient room in the array. |
536 * to ensure there is sufficient room in the array. |