code: public static int addOffset(int index, int offset, int size) {
  		index += offset;
  		if( index < 0 ) {
  			return size + index;
  		} else {
  			return index%size;
  		}
  	}
docs: Adds offset (positive or negative) to index in a circular buffer.
  @param index element in circular buffer
  @param offset offset.  |offset| < size
  @param size size of the circular buffer
  @return new index