Here you can find the source of compareIncarnations(List
Parameter | Description |
---|---|
e1 | a parameter |
e2 | a parameter |
public static int compareIncarnations(List<Integer> e1, List<Integer> e2)
//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; } }