| 101 | } |
| 102 | |
| 103 | public static int compareCharArrays( |
| 104 | final char[] c1, final int c1Offset, final int c1Len, |
| 105 | final char[] c2, final int c2Offset, final int c2Len) { |
| 106 | |
| 107 | /* we need the smallest range */ |
| 108 | int search_range = Math.min(c1Len, c2Len); |
| 109 | |
| 110 | for (int i = 0; i < search_range; i++) { |
| 111 | char c1x = c1[i+c1Offset]; |
| 112 | char c2x = c2[i+c2Offset]; |
| 113 | |
| 114 | if (c1x == c2x) { |
| 115 | /* the two words still match */ |
| 116 | continue; |
| 117 | } |
| 118 | |
| 119 | if (c1x < c2x) { |
| 120 | /* c1 is before */ |
| 121 | return -1; |
| 122 | } |
| 123 | |
| 124 | /* c1 is after */ |
| 125 | return 1; |
| 126 | } |
| 127 | |
| 128 | /* |
| 129 | * Scanned all common chars |
| 130 | */ |
| 131 | |
| 132 | if (c1Len == c2Len) { |
| 133 | /* the same */ |
| 134 | return 0; |
| 135 | } |
| 136 | |
| 137 | if (c1Len < c2Len) { |
| 138 | /* c1 is before */ |
| 139 | return -1; |
| 140 | } |
| 141 | |
| 142 | /* c1 is after */ |
| 143 | return 1; |
| 144 | } |
| 145 | |
| 146 | public static boolean equalsCharArrays( |
| 147 | final char[] c1, final int c1Offset, final int c1Len, |