public static boolean isOutOfBounds(int index, int length, int capacity) {
        return (index | length | capacity | (index + length) | (capacity - (index + length))) < 0;
    }
@Test
    public void testIsOutOfBounds() {
        assertFalse(isOutOfBounds(0, 0, 0));
        assertFalse(isOutOfBounds(0, 0, 1));
        assertFalse(isOutOfBounds(0, 1, 1));
        assertTrue(isOutOfBounds(1, 1, 1));
        assertTrue(isOutOfBounds(Integer.MAX_VALUE, 1, 1));
        assertTrue(isOutOfBounds(Integer.MAX_VALUE, Integer.MAX_VALUE, 1));
        assertTrue(isOutOfBounds(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE));
        assertFalse(isOutOfBounds(0, Integer.MAX_VALUE, Integer.MAX_VALUE));
        assertFalse(isOutOfBounds(0, Integer.MAX_VALUE - 1, Integer.MAX_VALUE));
        assertTrue(isOutOfBounds(0, Integer.MAX_VALUE, Integer.MAX_VALUE - 1));
        assertFalse(isOutOfBounds(Integer.MAX_VALUE - 1, 1, Integer.MAX_VALUE));
        assertTrue(isOutOfBounds(Integer.MAX_VALUE - 1, 1, Integer.MAX_VALUE - 1));
        assertTrue(isOutOfBounds(Integer.MAX_VALUE - 1, 2, Integer.MAX_VALUE));
        assertTrue(isOutOfBounds(1, Integer.MAX_VALUE, Integer.MAX_VALUE));
        assertTrue(isOutOfBounds(0, 1, Integer.MIN_VALUE));
        assertTrue(isOutOfBounds(0, 1, -1));
        assertTrue(isOutOfBounds(0, Integer.MAX_VALUE, 0));
    }