Java Iterator compareRanges(final Iterator i, final Iterator j)

Here you can find the source of compareRanges(final Iterator i, final Iterator j)

Description

compare Ranges

License

Open Source License

Declaration

public static <E extends Comparable<E>> int compareRanges(final Iterator<E> i, final Iterator<E> j) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Iterator;

public class Main {
    public static <E extends Comparable<E>> int compareRanges(final Iterator<E> i, final Iterator<E> j) {
        while (i.hasNext() && j.hasNext()) {
            final E a = i.next();
            final E b = j.next();
            final int ret = a.compareTo(b);
            if (ret != 0) {
                return ret;
            }/*www .j a  va  2 s .  c o  m*/
        }
        if (i.hasNext()) {
            return 1;
        }
        if (j.hasNext()) {
            return -1;
        }
        return 0;
    }
}

Related

  1. asList(final Iterator iterator)
  2. asList(Iterator it)
  3. asStringOn(StringBuffer sb, Iterator iter, String separator)
  4. cast(Iterator p)
  5. closeIterator(Iterator iterator)
  6. concatinateElements(Iterator it)
  7. concatIterators(final Iterator... iterators)
  8. concatLines(Iterator lineIterator)
  9. contains(final Iterator iter, final E item)