예제 #1
0
 public static <R, I, C extends Collection<R>> C collect(
     Iterable<? extends I> source, C destination, Transformer<R, I> transformer) {
   for (I item : source) {
     destination.add(transformer.transform(item));
   }
   return destination;
 }
예제 #2
0
 @NotNull
 private static <T, C extends Collection<T>> C copy(
     @NotNull C collection, @NotNull Iterable<? extends T> elements) {
   for (T element : elements) {
     collection.add(element);
   }
   return collection;
 }
예제 #3
0
 public static <T, C extends Collection<T>> C filter(
     Iterable<? extends T> source, C destination, Spec<? super T> filter) {
   for (T item : source) {
     if (filter.isSatisfiedBy(item)) {
       destination.add(item);
     }
   }
   return destination;
 }
예제 #4
0
파일: Maps.java 프로젝트: automenta/corenlp
 /**
  * Adds the value to the collection given by map.get(key). A new collection is created using the
  * supplied CollectionFactory.
  */
 public static <K, V, C extends Collection<V>> void putIntoValueCollection(
     Map<K, C> map, K key, V value, CollectionFactory<V> cf) {
   C c = map.get(key);
   if (c == null) {
     c = ErasureUtils.<C>uncheckedCast(cf.newCollection());
     map.put(key, c);
   }
   c.add(value);
 }