/** * Add all elements in the iterable to the collection. * * @param target * @param iterable * @return true if the target was modified, false otherwise */ public static <T> boolean addAll(Collection<T> target, Iterable<? extends T> iterable) { if (iterable instanceof Collection) { return target.addAll((Collection<? extends T>) iterable); } return Iterators.addAll(target, iterable.iterator()); }
@Override public Iterator<T> iterator() { return Iterators.concat(iterators(iterables)); } };
/** * * @param iterables * @return an iterator over iterators from the given iterable of iterables */ public static <T> Iterator<Iterator<? extends T>> iterators(Iterable<? extends Iterable<? extends T>> iterables) { return Iterators.transform(iterables.iterator(), Iterable::iterator); }
/** * Combine the iterables into a single one. * * @param iterables * @return a single combined iterable */ public static <T> Iterable<T> concat(final Iterable<? extends Iterable<? extends T>> iterables) { return () -> Iterators.concat(iterators(iterables)); }
/** * * @param iterables * @return an iterator over iterators from the given iterable of iterables */ public static <T> Iterator<Iterator<? extends T>> iterators(Iterable<? extends Iterable<? extends T>> iterables) { return Iterators.transform(iterables.iterator(), Iterable::iterator); }
/** * Combine the iterables into a single one. * * @param iterables * @return a single combined iterable */ public static <T> Iterable<T> concat(final Iterable<? extends Iterable<? extends T>> iterables) { return () -> Iterators.concat(iterators(iterables)); }
/** * * @param iterables * @return an iterator over iterators from the given iterable of iterables */ public static <T> Iterator<Iterator<? extends T>> iterators(Iterable<? extends Iterable<? extends T>> iterables) { return Iterators.transform(iterables.iterator(), Iterable::iterator); }
/** * Add all elements in the iterable to the collection. * * @param target * @param iterable * @return true if the target was modified, false otherwise */ public static <T> boolean addAll(Collection<T> target, Iterable<? extends T> iterable) { if (iterable instanceof Collection) { return target.addAll((Collection<? extends T>) iterable); } return Iterators.addAll(target, iterable.iterator()); }
/** * Combine the iterables into a single one. * * @param iterables * @return a single combined iterable */ public static <T> Iterable<T> concat(final Iterable<? extends Iterable<? extends T>> iterables) { return () -> Iterators.concat(iterators(iterables)); }
/** * * @param iterables * @return an iterator over iterators from the given iterable of iterables */ public static <T> Iterator<Iterator<? extends T>> iterators(Iterable<? extends Iterable<? extends T>> iterables) { return Iterators.transform(iterables.iterator(), Iterable::iterator); }
/** * Add all elements in the iterable to the collection. * * @param target * @param iterable * @return true if the target was modified, false otherwise */ public static <T> boolean addAll(Collection<T> target, Iterable<? extends T> iterable) { if (iterable instanceof Collection) { return target.addAll((Collection<? extends T>) iterable); } return Iterators.addAll(target, iterable.iterator()); }
/** * Combine the iterables into a single one. * * @param iterables * @return a single combined iterable */ public static <T> Iterable<T> concat(final Iterable<? extends Iterable<? extends T>> iterables) { return () -> Iterators.concat(iterators(iterables)); }
/** * @param iterables * @return an iterator over iterators from the given iterable of iterables */ public static <T> Iterator<Iterator<? extends T>> iterators(Iterable<? extends Iterable<? extends T>> iterables) { return Iterators.transform(iterables.iterator(), new Function<Iterable<? extends T>, Iterator<? extends T>>() { @Override public Iterator<? extends T> apply(Iterable<? extends T> ts) { return ts.iterator(); } }); }
/** * Add all elements in the iterable to the collection. * * @param target * @param iterable * @return true if the target was modified, false otherwise */ public static <T> boolean addAll(Collection<T> target, Iterable<? extends T> iterable) { if (iterable instanceof Collection) { return target.addAll((Collection<? extends T>) iterable); } return Iterators.addAll(target, iterable.iterator()); }
/** * Combine the iterables into a single one. * * @param iterables * @return a single combined iterable */ public static <T> Iterable<T> concat(final Iterable<? extends Iterable<? extends T>> iterables) { return () -> Iterators.concat(iterators(iterables)); }