14 #define QSSWAP(a, b, stmp) do { stmp = (a); (a) = (b); (b) = stmp; } while (0)
22 int i,
j, lo, hi, mid;
29 for (lo=0, hi=
n-1; lo < hi;) {
30 mid = lo + ((hi-lo) >> 1);
33 if (cand[lo].
key < cand[mid].
key)
35 if (cand[hi].
key > cand[mid].
key)
39 if (cand[lo].
key < cand[mid].
key)
43 QSSWAP(cand[mid], cand[hi], stmp);
47 for (
i=lo-1,
j=lo;
j<hi;
j++) {
48 if (cand[
j].
key >= pivot) {
54 QSSWAP(cand[
i], cand[hi], stmp);
86 int i,
j, lo, hi, mid;
93 for (lo=0, hi=
n-1; lo < hi;) {
94 mid = lo + ((hi-lo) >> 1);
97 if (cand[lo].
key > cand[mid].
key)
99 if (cand[hi].
key < cand[mid].
key)
103 if (cand[lo].
key > cand[mid].
key)
107 QSSWAP(cand[mid], cand[hi], stmp);
108 pivot = cand[hi].key;
111 for (
i=lo-1,
j=lo;
j<hi;
j++) {
112 if (cand[
j].
key <= pivot) {
118 QSSWAP(cand[
i], cand[hi], stmp);