@Override
    public void clear() {
        if (isEmpty()) {
            return;
        }

        if (begin < end) {
            Arrays.fill(elements, begin, end, null);
        } else {
            Arrays.fill(elements, 0, end, null);
            Arrays.fill(elements, begin, elements.length, null);
        }

        begin = -1;
        end = 0;
    }
@Test
    public void testClear() {
        CircularArrayList<String> list = new CircularArrayList<>();
        list.clear();
        assertEmpty(list);

        for (int i = 0; i < 20; i++) {
            list.add("str" + i);
        }
        list.clear();
        assertEmpty(list);

        for (int i = 10; i < 20; i++) {
            list.add("str" + i);
        }
        for (int i = 9; i >= 0; i--) {
            list.addFirst("str" + i);
        }
        list.clear();
        assertEmpty(list);
    }