| 1452 | } |
| 1453 | |
| 1454 | static void QuickSort(int* pSortBuffer, int iLeft, int iRight, unsigned int uSeed) |
| 1455 | { |
| 1456 | int iL, iR, n, index, iMid, iTmp; |
| 1457 | |
| 1458 | // Random |
| 1459 | unsigned int t=uSeed&31; |
| 1460 | t=(uSeed<<t)|(uSeed>>(32-t)); |
| 1461 | uSeed=uSeed+t+3; |
| 1462 | // Random end |
| 1463 | |
| 1464 | iL=iLeft; iR=iRight; |
| 1465 | n = (iR-iL)+1; |
| 1466 | assert(n>=0); |
| 1467 | index = (int) (uSeed%n); |
| 1468 | |
| 1469 | iMid=pSortBuffer[index + iL]; |
| 1470 | |
| 1471 | |
| 1472 | do |
| 1473 | { |
| 1474 | while (pSortBuffer[iL] < iMid) |
| 1475 | ++iL; |
| 1476 | while (pSortBuffer[iR] > iMid) |
| 1477 | --iR; |
| 1478 | |
| 1479 | if (iL <= iR) |
| 1480 | { |
| 1481 | iTmp = pSortBuffer[iL]; |
| 1482 | pSortBuffer[iL] = pSortBuffer[iR]; |
| 1483 | pSortBuffer[iR] = iTmp; |
| 1484 | ++iL; --iR; |
| 1485 | } |
| 1486 | } |
| 1487 | while (iL <= iR); |
| 1488 | |
| 1489 | if (iLeft < iR) |
| 1490 | QuickSort(pSortBuffer, iLeft, iR, uSeed); |
| 1491 | if (iL < iRight) |
| 1492 | QuickSort(pSortBuffer, iL, iRight, uSeed); |
| 1493 | } |
| 1494 | |
| 1495 | ///////////////////////////////////////////////////////////////////////////////////////////// |
| 1496 | ///////////////////////////////////////////////////////////////////////////////////////////// |
no test coverage detected