@Override
    public Object[] toArray() {
        return Arrays.copyOf(entries, size);
    }
This is an extremely expensive implementation of
{@link Set#retainAll(Collection)}. It is implemented as O(n**2).
vespajlib/src/main/java/com/yahoo/collections/ArraySet.java