class 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);

}