Java List Compare compare(List a, List b)

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

Description

compare

License

Apache License

Declaration

public static int compare(List<String> a, List<String> b) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.List;

public class Main {

    public static int compare(List<String> a, List<String> b) {
        if (a.size() == 0 || b.size() == 0) {
            return 0;
        }/*  www  .  j  ava  2  s .  c  o  m*/

        if (a.size() <= b.size()) {
            for (String x : a) {
                boolean z = false;
                for (String y : b) {
                    if (x.equals(y)) {
                        z = true;
                        break;
                    }
                }
                if (!z)
                    return 0;
            }
            return -1;
        } else {
            for (String x : b) {
                boolean z = false;
                for (String y : a) {
                    if (x.equals(y)) {
                        z = true;
                        break;
                    }
                }
                if (!z)
                    return 0;
            }
            return 1;
        }
    }
}

Related

  1. canonicalCompare(List o1, List o2, Comparator elemComparator)
  2. compare(List lhs, Collection rhs, List standard)
  3. compare(List> beanList1, List> beanList2, final int[] sortKeys, final boolean[] sortAscending, final boolean nullAlwaysFirst, final int naOrder)
  4. compare(List list1, List list2)
  5. compare(List strList1, List strList2)
  6. compare(List a, List b)
  7. compare(String str, List list)
  8. compareByList(List list, T a, T b)