@Override
    public boolean retainAll(Collection<?> elementsToRetain) {
        boolean setChanged = false;
        final int sizeBeforeRemovals = size;
        int visited = 0;

        for (int index = 0; index < table.length && visited < sizeBeforeRemovals; index++) {
            final Object storedElement = table[index];
            if (storedElement != null) {
                visited++;
                if (!elementsToRetain.contains(storedElement)) {
                    removeFromIndex(index);
                    setChanged = true;
                }
            }
        }

        return setChanged;
    }
@Test
    public void testRetainAll() {
        final OAHashSet<Integer> set = new OAHashSet<>(8);
        populateSet(set, 10);

        Collection<Integer> elementsToRetain = new ArrayList<>(10);
        for (int i = 0; i < 10; i++) {
            elementsToRetain.add(i);
        }

        final boolean retainedAll = set.retainAll(elementsToRetain);
        assertFalse("No elements should be removed", retainedAll);
        assertFalse(set.isEmpty());
    }