/** * Creates a {@code Spliterator} without knowledge of collection size. * * @return a {@code Spliterator} over the elements in this collection. */ @Override public Spliterator<E> spliterator() { return isSizeKnown() ? super.spliterator() : Spliterators.spliteratorUnknownSize(iterator(), 0); }
/** * Returns {@code true} if this set is empty. * This method avoids to invoke {@link #size()} unless it is cheap. * * @return {@code true} if this set is empty. */ @Override public boolean isEmpty() { return isSizeKnown() ? super.isEmpty() : !iterator().hasNext(); }
/** * Returns {@code true} if this set is empty. * This method avoids to invoke {@link #size()} unless it is cheap. * * @return {@code true} if this set is empty. */ @Override public boolean isEmpty() { return isSizeKnown() ? super.isEmpty() : !iterator().hasNext(); }
/** * Returns the elements in an array. * * @return an array containing all set elements. */ @Override public Object[] toArray() { return isSizeKnown() ? super.toArray() : toArray(new Object[32], true); }
/** * Returns the elements in the given array, or in a new array of the same type * if it was necessary to allocate more space. * * @param <T> the type array elements. * @param array where to store the elements. * @return an array containing all set elements. */ @Override @SuppressWarnings("SuspiciousToArrayCall") public <T> T[] toArray(final T[] array) { return isSizeKnown() ? super.toArray(array) : toArray(array, false); }
/** * Returns the elements in the given array, or in a new array of the same type * if it was necessary to allocate more space. * * @param <T> the type array elements. * @param array where to store the elements. * @return an array containing all set elements. */ @Override @SuppressWarnings("SuspiciousToArrayCall") public <T> T[] toArray(final T[] array) { return isSizeKnown() ? super.toArray(array) : toArray(iterator(), array, false); }
/** * Returns the elements in an array. * * @return an array containing all set elements. */ @Override public Object[] toArray() { return isSizeKnown() ? super.toArray() : toArray(iterator(), new Object[32], true); }