Java List Compare compareIncarnations(List e1, List e2)

Here you can find the source of compareIncarnations(List e1, List e2)

Description

compare two incarnation values.

License

Apache License

Parameter

Parameter Description
e1 a parameter
e2 a parameter

Return

the result of the comparison, encoded as follows: 0: equal. -1: first parameter smaller than second. 1: first param greater than second.

Declaration

public static int compareIncarnations(List<Integer> e1, List<Integer> e2) 

Method Source Code

//package com.java2s;
/**/*from w w  w .  j  a  v a2 s  .co  m*/
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.List;

public class Main {
    /**
     * compare two incarnation values. Simply do a lexicographic comparison.
     *
     * @param e1
     * @param e2
     * @return the result of the comparison, encoded as follows:
     *          0: equal.
     *          -1: first parameter smaller than second.
     *          1: first param greater than second.
     */
    public static int compareIncarnations(List<Integer> e1, List<Integer> e2) {
        for (int j = 0; j < e1.size(); j++) {
            if (e1.get(j) < e2.get(j))
                return -1;
            if (e1.get(j) > e2.get(j))
                return 1;
        }
        return 0;
    }
}

Related

  1. compare(List strList1, List strList2)
  2. compare(List a, List b)
  3. compare(String str, List list)
  4. compareByList(List list, T a, T b)
  5. compareFileLists(List expected, List gotten)
  6. compareList(List listA, List listB)
  7. compareList(Object eObj, Object rObj)
  8. compareLists(Class type, List list1, List list2)
  9. compareLists(final List list1, final List list2)