MCPcopy Create free account
hub / github.com/albertobsd/keyhunt / _partition

Function _partition

keyhunt.cpp:3584–3614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3582}
3583
3584int64_t _partition(struct address_value *arr, int64_t n) {
3585 struct address_value pivot;
3586 int64_t r,left,right;
3587 r = n/2;
3588 pivot = arr[r];
3589 left = 0;
3590 right = n-1;
3591 do {
3592 while(left < right && memcmp(arr[left].value,pivot.value,20) <= 0 ) {
3593 left++;
3594 }
3595 while(right >= left && memcmp(arr[right].value,pivot.value,20) > 0) {
3596 right--;
3597 }
3598 if(left < right) {
3599 if(left == r || right == r) {
3600 if(left == r) {
3601 r = right;
3602 }
3603 if(right == r) {
3604 r = left;
3605 }
3606 }
3607 _swap(&arr[right],&arr[left]);
3608 }
3609 }while(left < right);
3610 if(right != r) {
3611 _swap(&arr[right],&arr[r]);
3612 }
3613 return right;
3614}
3615
3616void _heapify(struct address_value *arr, int64_t n, int64_t i) {
3617 int64_t largest = i;

Callers 1

_introsortFunction · 0.70

Calls 1

_swapFunction · 0.70

Tested by

no test coverage detected