ObjIntIntArrayList { public boolean addToIntsIfMatch(int index, T e, int deltaA, int deltaB) { Objects.requireNonNull(e, "e must be not null"); if (deltaA < 0) { throw new IllegalArgumentException("deltaA must be >= 0"); } if (deltaB < 0) { throw new IllegalArgumentException("deltaB must be >= 0"); } if (index < 0 || index >= size) { throw new IndexOutOfBoundsException("index must be >=0 and <" + size); } final Object elm = objects[index]; if (!Objects.equals(elm, e)) { return false; } final long packedInts = ints[index]; final int oldA = unpackA(packedInts); final long newA = oldA + deltaA; if (newA < oldA) { return false; } final int oldB = unpackB(packedInts); final long newB = oldB + deltaB; if (newB < oldB) { return false; } ints[index] = packInts((int) newA, (int) newB); return true; } ObjIntIntArrayList(int initialCapacity); int size(); boolean addToIntsIfMatch(int index, T e, int deltaA, int deltaB); void add(final T e, final int a, int b); void clear(); void forEach(ObjIntIntConsumerOneArg<? super T, ? super A> onFile, A arg);  }
@Test(expected = IndexOutOfBoundsException.class) public void updateIfMatchShouldFailOnNegativeIndex() { ObjIntIntArrayList<Integer> list = new ObjIntIntArrayList<>(0); list.addToIntsIfMatch(-1, 1, 1, 1); }
@Test(expected = IndexOutOfBoundsException.class) public void updateIfMatchShouldFailBeyondSize() { ObjIntIntArrayList<Integer> list = new ObjIntIntArrayList<>(0); list.addToIntsIfMatch(0, 1, 1, 1); }