Java Collection Compare compare(Collection a, Collection b)

Here you can find the source of compare(Collection a, Collection b)

Description

compare

License

Open Source License

Declaration

public static <T extends Comparable<T>> int compare(Collection<T> a, Collection<T> b) 

Method Source Code

//package com.java2s;

import java.util.Collection;

import java.util.Iterator;

public class Main {
    public static <T extends Comparable<T>> int compare(Collection<T> a, Collection<T> b) {
        int d = a.size() - b.size();
        if (d != 0) {
            return d;
        }/*from   ww w.ja va2  s  . com*/

        Iterator<T> ai = a.iterator();
        Iterator<T> bi = b.iterator();
        while (ai.hasNext()) {
            d = ai.next().compareTo(bi.next());
            if (d != 0) {
                return d;
            }
        }

        return 0;
    }
}

Related

  1. compare(Collection c1, Collection c2)
  2. compare(Collection a, Collection b)
  3. compare(Collection lhs, Collection rhs)
  4. compare(final Collection o1, final Collection o2)
  5. compare(final Collection c0, final Collection c1, final Comparator c)
  6. compareAnyOrder(Collection c1, Collection c2)