@SuppressWarnings("unchecked") @Override public <T> T[] toArray(T[] a) { // TODO: Optimize this to only allocate a new array if the set size // is larger than the array.length. If the set size is smaller than // the array.length then copy the data into the array and set the // last element in the array to be null. final T[] resizedArray = (T[]) Array.newInstance( a.getClass().getComponentType(), complete(asyncSet.getAsImmutableSet()).size()); return complete(asyncSet.getAsImmutableSet()).toArray(resizedArray); }
@Override public Object[] toArray() { return complete(asyncSet.getAsImmutableSet()).stream().toArray(); }
@Override public Iterator<E> iterator() { return complete(asyncSet.getAsImmutableSet()).iterator(); }