@SuppressWarnings("unchecked")
    @Override
    public <T> T[] toArray(final T[] arg) {
        return Arrays.copyOf(entries, size, (Class<T[]>) arg.getClass());
    }
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/TinyIdentitySet.java