org.gridkit.jvmtool.event
Class MergeIterator<T>

java.lang.Object
  extended by org.gridkit.jvmtool.event.MergeIterator<T>
All Implemented Interfaces:
Iterator<T>

public class MergeIterator<T>
extends Object
implements Iterator<T>

Merges two Iterator into one.
Each of nested Iterators MUST produce ordered, duplicate free sequence of values.
Result would be ordered, duplicate free sequence of values present in either iterator.

Author:
Alexey Ragozin (alexey.ragozin@gmail.com)

Constructor Summary
MergeIterator(Iterator<T> a, Iterator<T> b, Comparator<T> cmp)
           
 
Method Summary
 boolean hasNext()
           
static
<T> Iterable<T>
merge(Iterable<T> a, Iterable<T> b)
           
static
<T> Iterable<T>
merge(Iterable<T> a, Iterable<T> b, Comparator<T> cmp)
           
static
<T> Iterator<T>
merge(Iterator<T> a, Iterator<T> b)
           
static
<T> Iterator<T>
merge(Iterator<T> a, Iterator<T> b, Comparator<T> cmp)
           
 T next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MergeIterator

public MergeIterator(Iterator<T> a,
                     Iterator<T> b,
                     Comparator<T> cmp)
Method Detail

merge

public static <T> Iterator<T> merge(Iterator<T> a,
                                    Iterator<T> b)

merge

public static <T> Iterator<T> merge(Iterator<T> a,
                                    Iterator<T> b,
                                    Comparator<T> cmp)

merge

public static <T> Iterable<T> merge(Iterable<T> a,
                                    Iterable<T> b)

merge

public static <T> Iterable<T> merge(Iterable<T> a,
                                    Iterable<T> b,
                                    Comparator<T> cmp)

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<T>

next

public T next()
Specified by:
next in interface Iterator<T>

remove

public void remove()
Specified by:
remove in interface Iterator<T>


Copyright © 2019. All Rights Reserved.