Java Utililty Methods Collection Add

List of utility methods to do Collection Add

Description

The list of methods to do Collection Add are organized into topic(s).

Method

voidaddAll(Collection ret, Object[] elements)
add All
if (elements != null)
    for (int i = 0; i < elements.length; i++)
        ret.add(elements[i]);
voidaddAll(Collection source, Collection target)
Adds all the elements in the source to target.
if (source instanceof List) {
    final List<?> list = (List<?>) source;
    for (int i = 0; i < list.size(); i++) {
        target.add(list.get(i));
} else {
    target.addAll(source);
booleanaddAll(Collection col, Iterable iterable)
add All
boolean celkovaZmena = false;
for (T tt : iterable) {
    boolean zmena = col.add(tt);
    celkovaZmena = celkovaZmena || zmena;
return celkovaZmena;
voidaddAll(Collection collection, Iterable toAdd)
Simple convenience method that adds the array elements in toAdd to the collection.
for (T t : toAdd) {
    collection.add(t);
booleanaddAll(Collection addTo, Iterable elementsToAdd)
add All
boolean modified = false;
for (E e : elementsToAdd) {
    modified |= addTo.add(e);
return modified;
booleanaddAll(Collection c, Iterable elts)
Add the given elements to a collection.
if (elts instanceof Collection<?>) {
    @SuppressWarnings("unchecked") 
    Collection<? extends E> eltsColl = (Collection<? extends E>) elts;
    return c.addAll(eltsColl);
} else {
    boolean result = false;
    for (E elt : elts) {
        result |= c.add(elt);
...
CollectionaddAll(Collection c, T... array)
Adds objects in array to the given collection
for (T obj : array)
    c.add(obj);
return c;
CollectionaddAll(Collection c, T... array)
Adds objects in array to the given collection
for (T obj : array) {
    c.add(obj);
return c;
booleanaddAll(Collection coll, Iterable it)
Adds all elements from an iterable to a collection.
boolean modified = false;
for (E e : it)
    modified = coll.add(e) || modified;
return modified;
voidaddAll(Collection collection, E... args)
Add all the elements in args into collection.
for (int i = 0; i < args.length; ++i) {
    collection.add(args[i]);