Lines Matching refs:middle
264 saidx_t *middle; in ss_pivot() local
268 middle = first + t / 2; in ss_pivot()
272 return ss_median3(Td, PA, first, middle, last - 1); in ss_pivot()
275 return ss_median5(Td, PA, first, first + t, middle, last - 1 - t, last - 1); in ss_pivot()
280 middle = ss_median3(Td, PA, middle - t, middle, middle + t); in ss_pivot()
282 return ss_median3(Td, PA, first, middle, last); in ss_pivot()
461 ss_rotate(saidx_t *first, saidx_t *middle, saidx_t *last) { in ss_rotate() argument
464 l = middle - first, r = last - middle; in ss_rotate()
466 if(l == r) { ss_blockswap(first, middle, l); break; } in ss_rotate()
468 a = last - 1, b = middle - 1; in ss_rotate()
476 a -= 1, b = middle - 1; in ss_rotate()
481 a = first, b = middle; in ss_rotate()
489 a += 1, b = middle; in ss_rotate()
503 saidx_t *first, saidx_t *middle, saidx_t *last, in ss_inplacemerge() argument
514 for(a = first, len = middle - first, half = len >> 1, r = -1; in ss_inplacemerge()
526 if(a < middle) { in ss_inplacemerge()
528 ss_rotate(a, middle, last); in ss_inplacemerge()
529 last -= middle - a; in ss_inplacemerge()
530 middle = a; in ss_inplacemerge()
531 if(first == middle) { break; } in ss_inplacemerge()
535 if(middle == last) { break; } in ss_inplacemerge()
546 saidx_t *first, saidx_t *middle, saidx_t *last, in ss_mergeforward() argument
552 bufend = buf + (middle - first) - 1; in ss_mergeforward()
553 ss_blockswap(buf, first, middle - first); in ss_mergeforward()
555 for(t = *(a = first), b = buf, c = middle;;) { in ss_mergeforward()
596 saidx_t *first, saidx_t *middle, saidx_t *last, in ss_mergebackward() argument
604 bufend = buf + (last - middle) - 1; in ss_mergebackward()
605 ss_blockswap(buf, middle, last - middle); in ss_mergebackward()
610 if(*(middle - 1) < 0) { p2 = PA + ~*(middle - 1); x |= 2; } in ss_mergebackward()
611 else { p2 = PA + *(middle - 1); } in ss_mergebackward()
612 for(t = *(a = last - 1), b = bufend, c = middle - 1;;) { in ss_mergebackward()
655 saidx_t *first, saidx_t *middle, saidx_t *last, in ss_swapmerge() argument
676 if((last - middle) <= bufsize) { in ss_swapmerge()
677 if((first < middle) && (middle < last)) { in ss_swapmerge()
678 ss_mergebackward(T, PA, first, middle, last, buf, depth); in ss_swapmerge()
681 STACK_POP(first, middle, last, check); in ss_swapmerge()
685 if((middle - first) <= bufsize) { in ss_swapmerge()
686 if(first < middle) { in ss_swapmerge()
687 ss_mergeforward(T, PA, first, middle, last, buf, depth); in ss_swapmerge()
690 STACK_POP(first, middle, last, check); in ss_swapmerge()
694 for(m = 0, len = MIN(middle - first, last - middle), half = len >> 1; in ss_swapmerge()
697 if(ss_compare(T, PA + GETIDX(*(middle + m + half)), in ss_swapmerge()
698 PA + GETIDX(*(middle - m - half - 1)), depth) < 0) { in ss_swapmerge()
705 lm = middle - m, rm = middle + m; in ss_swapmerge()
706 ss_blockswap(lm, middle, m); in ss_swapmerge()
707 l = r = middle, next = 0; in ss_swapmerge()
721 middle = lm, last = l, check = (check & 3) | (next & 4); in ss_swapmerge()
723 if((next & 2) && (r == middle)) { next ^= 6; } in ss_swapmerge()
725 first = r, middle = rm, check = (next & 3) | (check & 4); in ss_swapmerge()
728 if(ss_compare(T, PA + GETIDX(*(middle - 1)), PA + *middle, depth) == 0) { in ss_swapmerge()
729 *middle = ~*middle; in ss_swapmerge()
732 STACK_POP(first, middle, last, check); in ss_swapmerge()
753 saidx_t *b, *middle, *curbuf; in sssort() local
767 buf = middle = last - limit, bufsize = limit; in sssort()
769 middle = last, limit = 0; in sssort()
771 for(a = first, i = 0; SS_BLOCKSIZE < (middle - a); a += SS_BLOCKSIZE, ++i) { in sssort()
785 ss_mintrosort(T, PA, a, middle, depth); in sssort()
787 ss_insertionsort(T, PA, a, middle, depth); in sssort()
791 ss_swapmerge(T, PA, a - k, a, middle, buf, bufsize, depth); in sssort()
797 ss_mintrosort(T, PA, middle, last, depth); in sssort()
799 ss_insertionsort(T, PA, middle, last, depth); in sssort()
801 ss_inplacemerge(T, PA, first, middle, last, depth); in sssort()