MCPcopy Create free account
hub / github.com/google/re2j / qsortIntPair

Method qsortIntPair

java/com/google/re2j/CharClass.java:299–330  ·  view source on GitHub ↗
(int[] array, int left, int right)

Source from the content-addressed store, hash-verified

297 // qsortIntPair() quicksorts pairs of ints in |array| according to lt().
298 // Precondition: |left|, |right|, |this.len| must all be even; |this.len > 1|.
299 private static void qsortIntPair(int[] array, int left, int right) {
300 int pivotIndex = ((left + right) / 2) & ~1;
301 int pivotFrom = array[pivotIndex], pivotTo = array[pivotIndex + 1];
302 int i = left, j = right;
303
304 while (i <= j) {
305 while (i < right && cmp(array, i, pivotFrom, pivotTo) < 0) {
306 i += 2;
307 }
308 while (j > left && cmp(array, j, pivotFrom, pivotTo) > 0) {
309 j -= 2;
310 }
311 if (i <= j) {
312 if (i != j) {
313 int temp = array[i];
314 array[i] = array[j];
315 array[j] = temp;
316 temp = array[i + 1];
317 array[i + 1] = array[j + 1];
318 array[j + 1] = temp;
319 }
320 i += 2;
321 j -= 2;
322 }
323 }
324 if (left < j) {
325 qsortIntPair(array, left, j);
326 }
327 if (i < right) {
328 qsortIntPair(array, i, right);
329 }
330 }
331
332 // Exposed, since useful for debugging CharGroups too.
333 static String charClassToString(int[] r, int len) {

Callers 1

cleanClassMethod · 0.95

Calls 1

cmpMethod · 0.95

Tested by

no test coverage detected