@Test public void shouldIterateOverArray() throws NoSuchMethodException { final long[] lengths = {11}; final PointArray array = PointArray.newInstance(lengths[0]); initValues(lengths, array); PointArray.ElementIterator iter = array.iterator(); long sum = 0; long elementCount = 0; while (iter.hasNext()) { final long index = iter.getCursor(); final Point point = iter.next(); Assert.assertThat(valueOf(point.getX()), CoreMatchers.is(valueOf(index))); Assert.assertThat(valueOf(point.getY()), CoreMatchers.is(valueOf(index * 2))); sum += index; elementCount++; } long sum2 = 0; long elementCount2 = 0; for (final Point point : array) { sum2 += point.getX(); elementCount2++; } Assert.assertThat(valueOf(elementCount), CoreMatchers.is(valueOf(array.getLength()))); Assert.assertThat(valueOf(sum), CoreMatchers.is(valueOf(sum2))); Assert.assertThat(valueOf(elementCount), CoreMatchers.is(valueOf(elementCount2))); }
public static PointArray newInstance(final long length) { return StructuredArray.newInstance(PointArray.class, Point.class, length); }
PointArray extends StructuredArray<Point> { public static PointArray newInstance(final long length) { return StructuredArray.newInstance(PointArray.class, Point.class, length); } }
PointArray extends StructuredArray<Point> { public static PointArray newInstance(final long length) { return StructuredArray.newInstance(PointArray.class, Point.class, length); } PointArray(PointArray source);  PointArray(); }
PointArray extends StructuredArray<Point> { public static PointArray newInstance(final long length) { return StructuredArray.newInstance(PointArray.class, Point.class, length); } PointArray(PointArray source);  PointArray(); static PointArray newInstance(final long length); static PointArray newInstance(final long length,
                                           final CtorAndArgsProvider<Point> ctorAndArgsProvider); static PointArray newInstance(final long length, final long x, final long y); }
PointArray extends StructuredArray<Point> { public static PointArray newInstance(final long length) { return StructuredArray.newInstance(PointArray.class, Point.class, length); } PointArray(PointArray source);  PointArray(); static PointArray newInstance(final long length); static PointArray newInstance(final long length,
                                           final CtorAndArgsProvider<Point> ctorAndArgsProvider); static PointArray newInstance(final long length, final long x, final long y);  }