Go to the documentation of this file. 106 #define _GKQSORT_SWAP(a, b, t) ((void)((t = *a), (*a = *b), (*b = t))) 110 #define _GKQSORT_MAX_THRESH 4 113 #define _GKQSORT_STACK_SIZE (8 * sizeof(size_t)) 114 #define _GKQSORT_PUSH(top, low, high) (((top->_lo = (low)), (top->_hi = (high)), ++top)) 115 #define _GKQSORT_POP(low, high, top) ((--top, (low = top->_lo), (high = top->_hi))) 116 #define _GKQSORT_STACK_NOT_EMPTY (_stack < _top) 120 #define GK_MKQSORT(GKQSORT_TYPE,GKQSORT_BASE,GKQSORT_NELT,GKQSORT_LT) \ 122 GKQSORT_TYPE *const _base = (GKQSORT_BASE); \ 123 const size_t _elems = (GKQSORT_NELT); \ 124 GKQSORT_TYPE _hold; \ 134 if (_elems > _GKQSORT_MAX_THRESH) { \ 135 GKQSORT_TYPE *_lo = _base; \ 136 GKQSORT_TYPE *_hi = _lo + _elems - 1; \ 138 GKQSORT_TYPE *_hi; GKQSORT_TYPE *_lo; \ 139 } _stack[_GKQSORT_STACK_SIZE], *_top = _stack + 1; \ 141 while (_GKQSORT_STACK_NOT_EMPTY) { \ 142 GKQSORT_TYPE *_left_ptr; GKQSORT_TYPE *_right_ptr; \ 150 GKQSORT_TYPE *_mid = _lo + ((_hi - _lo) >> 1); \ 152 if (GKQSORT_LT (_mid, _lo)) \ 153 _GKQSORT_SWAP (_mid, _lo, _hold); \ 154 if (GKQSORT_LT (_hi, _mid)) \ 155 _GKQSORT_SWAP (_mid, _hi, _hold); \ 158 if (GKQSORT_LT (_mid, _lo)) \ 159 _GKQSORT_SWAP (_mid, _lo, _hold); \ 162 _left_ptr = _lo + 1; \ 163 _right_ptr = _hi - 1; \ 169 while (GKQSORT_LT (_left_ptr, _mid)) \ 172 while (GKQSORT_LT (_mid, _right_ptr)) \ 175 if (_left_ptr < _right_ptr) { \ 176 _GKQSORT_SWAP (_left_ptr, _right_ptr, _hold); \ 177 if (_mid == _left_ptr) \ 179 else if (_mid == _right_ptr) \ 184 else if (_left_ptr == _right_ptr) { \ 189 } while (_left_ptr <= _right_ptr); \ 196 if (_right_ptr - _lo <= _GKQSORT_MAX_THRESH) { \ 197 if (_hi - _left_ptr <= _GKQSORT_MAX_THRESH) \ 199 _GKQSORT_POP (_lo, _hi, _top); \ 204 else if (_hi - _left_ptr <= _GKQSORT_MAX_THRESH) \ 207 else if (_right_ptr - _lo > _hi - _left_ptr) { \ 209 _GKQSORT_PUSH (_top, _lo, _right_ptr); \ 214 _GKQSORT_PUSH (_top, _left_ptr, _hi); \ 227 GKQSORT_TYPE *const _end_ptr = _base + _elems - 1; \ 228 GKQSORT_TYPE *_tmp_ptr = _base; \ 229 register GKQSORT_TYPE *_run_ptr; \ 230 GKQSORT_TYPE *_thresh; \ 232 _thresh = _base + _GKQSORT_MAX_THRESH; \ 233 if (_thresh > _end_ptr) \ 234 _thresh = _end_ptr; \ 240 for (_run_ptr = _tmp_ptr + 1; _run_ptr <= _thresh; ++_run_ptr) \ 241 if (GKQSORT_LT (_run_ptr, _tmp_ptr)) \ 242 _tmp_ptr = _run_ptr; \ 244 if (_tmp_ptr != _base) \ 245 _GKQSORT_SWAP (_tmp_ptr, _base, _hold); \ 250 _run_ptr = _base + 1; \ 251 while (++_run_ptr <= _end_ptr) { \ 252 _tmp_ptr = _run_ptr - 1; \ 253 while (GKQSORT_LT (_run_ptr, _tmp_ptr)) \ 257 if (_tmp_ptr != _run_ptr) { \ 258 GKQSORT_TYPE *_trav = _run_ptr + 1; \ 259 while (--_trav >= _run_ptr) { \ 260 GKQSORT_TYPE *_hi; GKQSORT_TYPE *_lo; \ 263 for (_hi = _lo = _trav; --_lo >= _tmp_ptr; _hi = _lo) \
gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:18