List of usage examples for java.util Collection add
boolean add(E e);
From source file:Main.java
final public static <T> Collection<T> nonMatched(Collection<T> tested, Collection<T> sources) { Collection<T> nonMatched = new ArrayList<T>(); for (T source : sources) { if (!tested.contains(source)) { nonMatched.add(source); }/*from w ww . j av a 2s . co m*/ } return nonMatched; }
From source file:Main.java
public static void addAll(final int[] src, final Collection<Integer> dst) { if (src == null) return;//w w w .j a v a2 s. c o m for (final int l : src) dst.add(l); }
From source file:Main.java
/** * Appends the values returned by an iterator to the passed collection. *//*ww w. j a va2 s .com*/ public static <T> void addAll(Collection<T> coll, Iterator<T> src) { while (src.hasNext()) coll.add(src.next()); }
From source file:Main.java
public static <T> T addIfNotExists(Collection<T> collection, Predicate<T> predicate, T element) { if (!Iterables.contains(collection, predicate)) { collection.add(element); }//from w ww .j a v a 2 s . c o m return element; }
From source file:Main.java
static <V> void addAll(final Collection<V> collection, final Iterable<V> values) { if (values != null) { for (final V value : values) { collection.add(value); }/* w w w . ja v a2 s. c o m*/ } }
From source file:com.fivesticks.time.timeclock.TimeclockEventEnum.java
public static Collection getCollection() { Collection ret = new ArrayList(); ret.add(CLOCK_IN); ret.add(CLOCK_OUT);/*from w w w .j a v a2 s.c o m*/ ret.add(BREAK_START); ret.add(BREAK_STOP); return ret; }
From source file:Main.java
public static <T> int addAll(final T[] source, final Collection<T> destination) { int count = 0; for (final T sourceItem : source) { destination.add(sourceItem); ++count;/*from ww w. jav a 2 s .c om*/ } return count; }
From source file:Main.java
/** * This function filters the input collection and returns a collection of elements ending with specified input. * @param coll//from w w w . java2 s .co m * @param str * @return Filtered Collection<String> */ public static Collection<String> endsWithString(Collection<String> coll, final String str) { Collection<String> list = new ArrayList<String>(); for (String item : coll) { if (item.endsWith(str)) { list.add(item); } } return list; }
From source file:Main.java
/** * Adds all elements from an iterable to a collection. * @param <E> element class.//from w w w . ja v a2 s . c om * @param coll the collection to which the elements are added. * @param it the iterable providing the elements to add. * @return <code>true</code> if the collection was modified, * <code>false</code> otherwise. */ public static <E> boolean addAll(Collection<E> coll, Iterable<? extends E> it) { boolean modified = false; for (E e : it) modified = coll.add(e) || modified; return modified; }
From source file:Main.java
public static <T> void fromArrayToCollection(T[] a, Collection<T> c) { if (c == null) throw new NullPointerException("Collection must be not null"); for (T e : a) { c.add(e); }// ww w . java 2 s. co m }