/** * Stores all of the elements in this set into {@code target}. An * {@link UnsupportedOperationException} will be thrown if the length of {@code target} does not * match the size of this set. * * @return an array containing all the elements in this set. * @throws UnsupportedOperationException if the length of {@code target} does not equal the size * of this set. * @since 1.0 */ default E[] toArray(E[] target) { if (target.length != size()) { throw new UnsupportedOperationException("Length of target array must equal the size of the set."); } int index = 0; for (E element : this) { target[index++] = element; } return target; } }
/** * Stores all of the elements in this set into {@code target}. An * {@link UnsupportedOperationException} will be thrown if the length of {@code target} does not * match the size of this set. * * @return an array containing all the elements in this set. * @throws UnsupportedOperationException if the length of {@code target} does not equal the size * of this set. * @since 1.0 */ default E[] toArray(E[] target) { if (target.length != size()) { throw new UnsupportedOperationException("Length of target array must equal the size of the set."); } int index = 0; for (E element : this) { target[index++] = element; } return target; } }
private EconomicMapImpl(Equivalence strategy, UnmodifiableEconomicSet<K> other, boolean isSet) { this(strategy, isSet); if (!initFrom(other)) { init(other.size()); addAll(other); } }
private EconomicMapImpl(Equivalence strategy, UnmodifiableEconomicSet<K> other, boolean isSet) { this(strategy, isSet); if (!initFrom(other)) { init(other.size()); addAll(other); } }