@Test public void testStride() throws InvalidRangeException { int nx = 1237; Range r = new Range(0, nx - 1, 9); System.out.printf("%s%n", r); System.out.printf("%d %d %d %d%n", r.first(), r.last(), r.stride(), r.length()); Assert.assertEquals(0, r.first()); Assert.assertEquals(9, r.stride()); Assert.assertEquals(138, r.length()); Assert.assertEquals(1233, r.last()); Section s = new Section(r, r); Section.Iterator iter = s.getIterator(new int[] {nx, nx}); int[] iterResult = new int[2]; int count = 0; for (int y = r.first(); y <= r.last(); y += r.stride()) { for (int x = r.first(); x <= r.last(); x += r.stride()) { assert iter.hasNext(); int iterN = iter.next(iterResult); assert iterResult[0] == y; assert iterResult[1] == x; assert iterN == y * nx + x; count++; } } Assert.assertEquals(138 * 138, count); }
public int stride() { return stride; }
Range implements RangeIterator { public int stride() { return stride; } }
Range implements RangeIterator { public int stride() { return stride; } private  Range(); private  Range(String name, int length);  Range(int first, int last);  Range(int length);  Range(String name, int first, int last);  Range(int first, int last, int stride);  Range(String name, int first, int last, int stride); protected  Range(String name, int first, int last, int stride, int length); }
Range implements RangeIterator { public int stride() { return stride; } private  Range(); private  Range(String name, int length);  Range(int first, int last);  Range(int length);  Range(String name, int first, int last);  Range(int first, int last, int stride);  Range(String name, int first, int last, int stride); protected  Range(String name, int first, int last, int stride, int length); static Range make(String name, int len); static Range make(int first, int last); @Deprecated Range setStride(int stride); Range copyWithStride(int stride); @Override Range copyWithName(String name); String getName(); int first(); int last(); int length(); int stride(); boolean contains(int want); Range compose(Range r); Range compact(); int element(int i); int index(int want); Range intersect(Range r); boolean intersects(Range r); boolean past(Range want); Range shiftOrigin(int origin); Range union(Range r); int getFirstInInterval(int start); String toString(); boolean equals(Object o); int hashCode(); Iterator<Integer> getIterator(); @Override Iterator<Integer> iterator(); }
Range implements RangeIterator { public int stride() { return stride; } private  Range(); private  Range(String name, int length);  Range(int first, int last);  Range(int length);  Range(String name, int first, int last);  Range(int first, int last, int stride);  Range(String name, int first, int last, int stride); protected  Range(String name, int first, int last, int stride, int length); static Range make(String name, int len); static Range make(int first, int last); @Deprecated Range setStride(int stride); Range copyWithStride(int stride); @Override Range copyWithName(String name); String getName(); int first(); int last(); int length(); int stride(); boolean contains(int want); Range compose(Range r); Range compact(); int element(int i); int index(int want); Range intersect(Range r); boolean intersects(Range r); boolean past(Range want); Range shiftOrigin(int origin); Range union(Range r); int getFirstInInterval(int start); String toString(); boolean equals(Object o); int hashCode(); Iterator<Integer> getIterator(); @Override Iterator<Integer> iterator(); static final Range EMPTY; static final Range ONE; static final Range VLEN; }