public static boolean addAll(final FloatCollection collection, Collection<? extends Float> another) { if (collection == another) throw new IllegalArgumentException(); long maxPossibleSize = collection.sizeAsLong() + Containers.sizeAsLong(another); collection.ensureCapacity(maxPossibleSize); if (another instanceof FloatCollection) { if (another instanceof InternalFloatCollectionOps) { return ((InternalFloatCollectionOps) another).reverseAddAllTo(collection); } else { class AddAll implements FloatConsumer { boolean collectionChanged = false; @Override public void accept(float value) { collectionChanged |= collection.add(value); } } AddAll addAll = new AddAll(); ((FloatCollection) another).forEach(addAll); return addAll.collectionChanged; } } else { boolean collectionChanged = false; for (Float v : another) { collectionChanged |= collection.add(v.floatValue()); } return collectionChanged; } }
public static boolean addAll(final FloatCollection collection, Collection<? extends Float> another) { if (collection == another) throw new IllegalArgumentException(); long maxPossibleSize = collection.sizeAsLong() + Containers.sizeAsLong(another); collection.ensureCapacity(maxPossibleSize); if (another instanceof FloatCollection) { if (another instanceof InternalFloatCollectionOps) { return ((InternalFloatCollectionOps) another).reverseAddAllTo(collection); } else { class AddAll implements FloatConsumer { boolean collectionChanged = false; @Override public void accept(float value) { collectionChanged |= collection.add(value); } } AddAll addAll = new AddAll(); ((FloatCollection) another).forEach(addAll); return addAll.collectionChanged; } } else { boolean collectionChanged = false; for (Float v : another) { collectionChanged |= collection.add(v.floatValue()); } return collectionChanged; } }