@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); }
@SuppressWarnings("unchecked") @Override public boolean remove(Object o) { return complete(asyncSet.remove((E) o)); }
@Override public boolean add(E e) { return complete(asyncSet.add(e)); }
@Override public Object[] toArray() { return complete(asyncSet.getAsImmutableSet()).stream().toArray(); }
@SuppressWarnings("unchecked") @Override public boolean contains(Object o) { return complete(asyncSet.contains((E) o)); }
@Override public Iterator<E> iterator() { return complete(asyncSet.getAsImmutableSet()).iterator(); }
@Override public int size() { return complete(asyncSet.size()); }
@Override public boolean isEmpty() { return complete(asyncSet.isEmpty()); }
@Override public void removeListener(SetEventListener<E> listener) { complete(asyncSet.removeListener(listener)); }
@Override public void addListener(SetEventListener<E> listener) { complete(asyncSet.addListener(listener)); }
@Override public void clear() { complete(asyncSet.clear()); }
@SuppressWarnings("unchecked") @Override public boolean removeAll(Collection<?> c) { return complete(asyncSet.removeAll((Collection<? extends E>) c)); }
@Override public boolean addAll(Collection<? extends E> c) { return complete(asyncSet.addAll(c)); }