Utility for adding the contents of an iterable to a collection.
@hide unsupported on Android
180213
public static <T, U extends Collection<T>> U addAllTo(Iterable<T> source, U target) {
        for (T item : source) {
            target.add(item);
        }
        return target;
    }
1149234
def append(self, value):
        """"""
        return super(Collection, self).append(
            self._ensure_value_is_valid(value))
420657
public static <T> List<T> iterableToList(Iterable<T> iterable) {
        if (iterable == null) {
            return Collections.emptyList();
        }
        if (iterable instanceof List) {
            return (List<T>) iterable;
        }
        Iterator<T> i = iterable.iterator();
        if (i.hasNext()) {
            List<T> list = new ArrayList<>();
            while (i.hasNext()) {
                list.add(i.next());
            }
            return list;
        }
        return Collections.emptyList();
    }
1016366
private static <E> Collection<E> toCollection(Iterable<E> iterable) {
		return (iterable instanceof Collection) ? (Collection<E>)iterable : Lists.newArrayList(iterable.iterator());
	}
594185
public static <T> Collection<T> flatten(Iterable<? extends Iterable<T>> iterable)
    {
        return Iterate.flatCollect(iterable, Functions.<Iterable<T>>identity());
    }
210266
def extend(self, iterable):
        
        with self.lock:
            for item in iterable:
                self.append(item)
677328
function collectionLoader(collection, config) {
  collection._addView = collection.addView.bind(collection);
  var fn = collection.view;

  collection.define('view', function() {
    var view = fn.apply(this, arguments);
    utils.contents.sync(view);
    return view;
  });

  /**
   * Patches the `.addViews` method to support glob patterns.
   *
   * @param {Object|String} `key` View name or object.
   * @param {Object} `value` View options, when key is a string.
   * @return {Object}
   */

  collection.define('addView', function(key, value) {
    return this._addView.apply(this, arguments);
  });

  /**
   * Patches the `.addViews` method to support glob patterns.
   *
   * @param {Object|String} `key` View name or object.
   * @param {Object} `value` View options, when key is a string.
   * @return {Object}
   */

  collection.define('addViews', function(key, value) {
    this.load.apply(this, arguments);
    return this;
  });

  collection.define('loadView', function(filepath, options) {
    this.load.apply(this, arguments);
    return this;
  });

  collection.define('loadViews', function(patterns, options) {
    this.load.apply(this, arguments);
    return this;
  });

  collection.define('load', function() {
    return load('_addView', config).apply(this, arguments);
  });
}
654729
public static <T> List<T> iterToList(final Iterable<T> it) {
        if (it instanceof List) {
            return (List<T>) it;
        }
        if (it == null) {
            return null;
        }

        final List<T> ar = new ArrayList<T>();
        for (final T o : it) {
            ar.add(o);
        }

        return ar;
    }
821857
private void appendList(Output out, Collection collection, String separator, boolean areColumns) {
        Iterator it = collection.iterator();
        boolean hasNext = it.hasNext();
        //boolean areColumns = (columns == collection);

        while (hasNext) {
            Outputable sqlToken = (Outputable) it.next();
            hasNext = it.hasNext();
            sqlToken.write(out);
            if (areColumns) {
                Column column = (Column) sqlToken;
                String columnAlias = column.getAlias();
                if (columnAlias != null) {
                    out.print(" AS ");
                    out.print("\"");
                    out.print(columnAlias);
                    out.print("\"");
                }
            }
            if (hasNext) {
                out.print(separator);
                out.println();
            }
        }
    }
1099000
private boolean appendList(StringBuilder builder, Object value)
    {
        boolean isPresent = false;
        if (value instanceof Collection)
        {
            Collection collection = ((Collection) value);
            isPresent = true;
            builder.append(Constants.OPEN_SQUARE_BRACKET);
            for (Object o : collection)
            {
                // Allowing null values.
                appendValue(builder, o != null ? o.getClass() : null, o, false);
                builder.append(Constants.COMMA);
            }
            if (!collection.isEmpty())
            {
                builder.deleteCharAt(builder.length() - 1);
            }
            builder.append(Constants.CLOSE_SQUARE_BRACKET);

        }
        else
        {
            appendValue(builder, value.getClass(), value, false);
        }
        return isPresent;
    }
1004422
def extend(self, iterable):
        """"""
        return super(Collection, self).extend(
            self._ensure_iterable_is_valid(iterable))
806152
public static <T> List<T> list(Iterable<T> iterable)
	{
		List<T> list = new ArrayList<T>();

		for (T item : iterable)
		{
			list.add(item);
		}
		return list;
	}
237947
public final TransposeDataCollection put(Object key, TransposeDataCollection value) {
        return internalData.put(key, value);
    }
419646
public void add(String name, Iterable<?> value) {
		if (value != null) {
			this.content.put(name, value);
		}
	}
894534
public static <T> Collection<T> addNotNull(Collection<T> to, T what) {
        Collection<T> data = safeCollection(to);
        if (what != null) {
            data.add(what);
        }
        return data;
    }
516481
@Override
    public scala.collection.Iterable<String> displayableElements() {
        LinkedList<String> elements = new LinkedList<>();
        if (geographicalLocation.nonEmpty()) {
            elements.add("Lat=" + geographicalLocation.get()._1());
            elements.add("Long=" + geographicalLocation.get()._2());
        }
        if (isSecret.nonEmpty() && isSecret.get()) {
            elements.add("IsSecret=True");
        }

        // Also possible to build a Scala collection directly in Java code, but building in Java and converting at
        // the very end is probably easier for Java developers than having to figure out the Scala collection classes
        // and deal with the annoying Java-interop syntax, e.g., to rewrite the Scala code "myArray += valToInsert" in
        // Java would look like "myArray.$plus$eq(valToInsert);", which we'd rather avoid.

        return linkedListToScalaIterable(elements);
    }
373715
Collection<V> wrapCollection(@Nullable K key, Collection<V> collection) {
    // We don't deal with NavigableSet here yet for GWT reasons -- instead,
    // non-GWT TreeMultimap explicitly overrides this and uses NavigableSet.
    if (collection instanceof SortedSet) {
      return new WrappedSortedSet(key, (SortedSet<V>) collection, null);
    } else if (collection instanceof Set) {
      return new WrappedSet(key, (Set<V>) collection);
    } else if (collection instanceof List) {
      return wrapList(key, (List<V>) collection, null);
    } else {
      return new WrappedCollection(key, collection, null);
    }
  }