@Test public void calculateNextIndex() throws Exception { CircularIndex index = new CircularIndex(4); Assert.assertEquals(1, index.calculateNewIndex(0, 1)); Assert.assertEquals(2, index.calculateNewIndex(1, 1)); Assert.assertEquals(3, index.calculateNewIndex(2, 1)); Assert.assertEquals(0, index.calculateNewIndex(3, 1)); Assert.assertEquals(3, index.calculateNewIndex(0, -1)); Assert.assertEquals(2, index.calculateNewIndex(0, -2)); }
protected long calculateNewIndex(long index, long offset) { return (index + capacity + offset) % capacity; }
CircularIndex { protected long calculateNewIndex(long index, long offset) { return (index + capacity + offset) % capacity; } }
CircularIndex { protected long calculateNewIndex(long index, long offset) { return (index + capacity + offset) % capacity; } CircularIndex(long capacity);  CircularIndex(long capacity, boolean resetOnZero);  CircularIndex(long capacity, long first, long size);  CircularIndex(long capacity, long first, long size, boolean resetOnZero); }
CircularIndex { protected long calculateNewIndex(long index, long offset) { return (index + capacity + offset) % capacity; } CircularIndex(long capacity);  CircularIndex(long capacity, boolean resetOnZero);  CircularIndex(long capacity, long first, long size);  CircularIndex(long capacity, long first, long size, boolean resetOnZero); void reset(); long getCapacity(); long getMaxSize(); long getSize(); boolean isEmpty(); boolean isFull(); boolean addLast(); boolean addFirst(); boolean removeLast(); boolean removeFirst(); long getFirst(); long getLast(); long getNextLast(); long getNextFirst(); @Override String toString(); }
CircularIndex { protected long calculateNewIndex(long index, long offset) { return (index + capacity + offset) % capacity; } CircularIndex(long capacity);  CircularIndex(long capacity, boolean resetOnZero);  CircularIndex(long capacity, long first, long size);  CircularIndex(long capacity, long first, long size, boolean resetOnZero); void reset(); long getCapacity(); long getMaxSize(); long getSize(); boolean isEmpty(); boolean isFull(); boolean addLast(); boolean addFirst(); boolean removeLast(); boolean removeFirst(); long getFirst(); long getLast(); long getNextLast(); long getNextFirst(); @Override String toString();  }