@Test public void testFlip() { int[] shape = new int[] {1, 2, 3}; IndexFn index = IndexFn.builder(shape).build(); assertThat(index.toString()).isEqualTo("0, 1, 2, 3, 4, 5"); IndexFn indexf1 = index.flip(1); assertThat(index.toString()).isEqualTo("0, 1, 2, 3, 4, 5"); assertThat(indexf1.toString()).isEqualTo("3, 4, 5, 0, 1, 2"); IndexFn indexf2 = index.flip(2); assertThat(indexf2.toString()).isEqualTo("2, 1, 0, 5, 4, 3"); }
IndexFn flip(int index) { Preconditions.checkArgument(index >= 0 && index < rank); Preconditions.checkArgument(shape[index] >= 0); IndexFn.Builder ib = this.toBuilder(); ib.offset += stride[index] * (shape[index] - 1); ib.stride[index] = -stride[index]; ib.canonicalOrder = false; return ib.build(); }
IndexFn implements Iterable<Integer> { IndexFn flip(int index) { Preconditions.checkArgument(index >= 0 && index < rank); Preconditions.checkArgument(shape[index] >= 0); IndexFn.Builder ib = this.toBuilder(); ib.offset += stride[index] * (shape[index] - 1); ib.stride[index] = -stride[index]; ib.canonicalOrder = false; return ib.build(); } }
IndexFn implements Iterable<Integer> { IndexFn flip(int index) { Preconditions.checkArgument(index >= 0 && index < rank); Preconditions.checkArgument(shape[index] >= 0); IndexFn.Builder ib = this.toBuilder(); ib.offset += stride[index] * (shape[index] - 1); ib.stride[index] = -stride[index]; ib.canonicalOrder = false; return ib.build(); } private  IndexFn(Builder builder); }
IndexFn implements Iterable<Integer> { IndexFn flip(int index) { Preconditions.checkArgument(index >= 0 && index < rank); Preconditions.checkArgument(shape[index] >= 0); IndexFn.Builder ib = this.toBuilder(); ib.offset += stride[index] * (shape[index] - 1); ib.stride[index] = -stride[index]; ib.canonicalOrder = false; return ib.build(); } private  IndexFn(Builder builder); int get(int... index); int getRank(); Section getSection(); int[] getShape(); int getShape(int index); Iterator<Integer> iterator(); Iterator<Integer> iterator(int start, long length); long length(); String toString(); static Builder builder(int rank); static Builder builder(int[] shape); Builder toBuilder(); }
IndexFn implements Iterable<Integer> { IndexFn flip(int index) { Preconditions.checkArgument(index >= 0 && index < rank); Preconditions.checkArgument(shape[index] >= 0); IndexFn.Builder ib = this.toBuilder(); ib.offset += stride[index] * (shape[index] - 1); ib.stride[index] = -stride[index]; ib.canonicalOrder = false; return ib.build(); } private  IndexFn(Builder builder); int get(int... index); int getRank(); Section getSection(); int[] getShape(); int getShape(int index); Iterator<Integer> iterator(); Iterator<Integer> iterator(int start, long length); long length(); String toString(); static Builder builder(int rank); static Builder builder(int[] shape); Builder toBuilder();  }