@Test public void merge() { List<Source<IntBuf>> cursors = new ArrayList<>(); cursors.add(Sources.wrap(array(1, 4, 7))); cursors.add(Sources.wrap(array(2, 5, 8))); cursors.add(Sources.wrap(array(3, 6, 9))); check(Sources.merge(cursors, IntBuf.COMPARATOR), 1, 2, 3, 4, 5, 6, 7, 8, 9); }
public static <T> Source<T> merge( List<? extends Source<? extends T>> sortedSources, Comparator<? super T> comparator) { if (sortedSources.isEmpty()) { return empty(); } else if (sortedSources.size() == 1) { @SuppressWarnings("unchecked") Source<T> source = (Source<T>) sortedSources.get(0); return source; } return new HeapSource<>(sortedSources, comparator); }
Sources { public static <T> Source<T> merge( List<? extends Source<? extends T>> sortedSources, Comparator<? super T> comparator) { if (sortedSources.isEmpty()) { return empty(); } else if (sortedSources.size() == 1) { @SuppressWarnings("unchecked") Source<T> source = (Source<T>) sortedSources.get(0); return source; } return new HeapSource<>(sortedSources, comparator); } }
Sources { public static <T> Source<T> merge( List<? extends Source<? extends T>> sortedSources, Comparator<? super T> comparator) { if (sortedSources.isEmpty()) { return empty(); } else if (sortedSources.size() == 1) { @SuppressWarnings("unchecked") Source<T> source = (Source<T>) sortedSources.get(0); return source; } return new HeapSource<>(sortedSources, comparator); } private  Sources(); }
Sources { public static <T> Source<T> merge( List<? extends Source<? extends T>> sortedSources, Comparator<? super T> comparator) { if (sortedSources.isEmpty()) { return empty(); } else if (sortedSources.size() == 1) { @SuppressWarnings("unchecked") Source<T> source = (Source<T>) sortedSources.get(0); return source; } return new HeapSource<>(sortedSources, comparator); } private  Sources(); static Source<T> empty(); @SafeVarargs static Source<T> wrap(T... values); static Source<T> wrap(Iterator<? extends T> iterator); static Source<T> concat(List<? extends Source<? extends T>> sources); static Source<T> merge(
            List<? extends Source<? extends T>> sortedSources,
            Comparator<? super T> comparator); }
Sources { public static <T> Source<T> merge( List<? extends Source<? extends T>> sortedSources, Comparator<? super T> comparator) { if (sortedSources.isEmpty()) { return empty(); } else if (sortedSources.size() == 1) { @SuppressWarnings("unchecked") Source<T> source = (Source<T>) sortedSources.get(0); return source; } return new HeapSource<>(sortedSources, comparator); } private  Sources(); static Source<T> empty(); @SafeVarargs static Source<T> wrap(T... values); static Source<T> wrap(Iterator<? extends T> iterator); static Source<T> concat(List<? extends Source<? extends T>> sources); static Source<T> merge(
            List<? extends Source<? extends T>> sortedSources,
            Comparator<? super T> comparator);  }