Merging several sorted collections, with different sizes, into one sorted collection via PriorityQueue.
Input collections are wrapped by implementation of PriorityQMergeSort and added to PriorityQMergeSorter
Java 1.7 or higher
- Creates your own implemetation of PriorityQMergeSort to wrap your source collections.
 - Creates PriorityQMergeSorter and put your wrapped collections into it.
 - Obtains elements one by one from the PriorityQMergeSorter
 
- Example code sorting sorted List of Long elements.
 
private static Random random = new Random();
public static void main(String[] args) {
        PriorityQMergeSorter<ListElement<List<Long>, Long>, List<Long>, Long> prioritySort = new PriorityQMergeSorter<>();
        prioritySort.add(createElement());
        prioritySort.add(createElement());
        prioritySort.add(createElement());
        while (prioritySort.hasElement()) {
                System.out.println(prioritySort.get());
        }
}
private static ListElement<List<Long>, Long> createElement() {
        List<Long> list = new ArrayList<>();
        fillList(list,random.nextInt(100));
        return new ListElement<List<Long>, Long>(list);
}
private static void fillList(List<Long> list, int size) {
        for (int i = 0; i < size; i++) {
                 list.add(Long.valueOf(random.nextInt(100)));
        }
        Collections.sort(list);
}You can find implementation of ListElement here.