OSDN Git Service

422bb235157cce5f4e7d686773e33fabf0c89ad6
[chemicraft/chemicraft.git] / common / chemicraft / util / CompaeatorFormulaPart.java
1 package chemicraft.util;
2
3 import java.util.Arrays;
4 import java.util.Comparator;
5
6 public class CompaeatorFormulaPart implements Comparator<FormulaPart> {
7
8         @Override
9         public int compare(FormulaPart o1, FormulaPart o2) {
10                 int i = 0;
11                 byte[] var1Byte = o1.getAtom().getBytes();
12                 byte[] var2Byte = o2.getAtom().getBytes();
13                 while (var1Byte.length < i && var2Byte.length < i) {
14                         if (var1Byte[i] == var2Byte[i]) {
15                                 i++;
16                                 continue;
17                         }
18                         if (var1Byte[i] < var2Byte[i]) {
19                                 return -1;
20                         }
21                         if (var1Byte[i] > var2Byte[i]) {
22                                 return 1;
23                         }
24                 }
25                 return 0;
26         }
27
28 }