/** * Merges two sorted Collections, a and b, into a single, sorted List * such that the natural ordering of the elements is retained. * <p> * Uses the standard O(n) merge algorithm for combining two sorted lists. * * @param <O> the element type * @param a the first collection, must not be null * @param b the second collection, must not be null * @return a new sorted List, containing the elements of Collection a and b * @throws NullPointerException if either collection is null * @since 4.0 */ public static <O extends Comparable<? super O>> List<O> collate(Iterable<? extends O> a, Iterable<? extends O> b) { return collate(a, b, ComparatorUtils.<O>naturalComparator(), true); }
/** * Merges two sorted Collections, a and b, into a single, sorted List * such that the natural ordering of the elements is retained. * <p> * Uses the standard O(n) merge algorithm for combining two sorted lists. * * @param <O> the element type * @param a the first collection, must not be null * @param b the second collection, must not be null * @param includeDuplicates if {@code true} duplicate elements will be retained, otherwise * they will be removed in the output collection * @return a new sorted List, containing the elements of Collection a and b * @throws NullPointerException if either collection is null * @since 4.0 */ public static <O extends Comparable<? super O>> List<O> collate(final Iterable<? extends O> a, final Iterable<? extends O> b, final boolean includeDuplicates) { return collate(a, b, ComparatorUtils.<O>naturalComparator(), includeDuplicates); }