#include <corecrt_internal.h>
#include <search.h>
Go to the source code of this file.
|
#define | BEGIN_PRAGMA_OPTIMIZE_DISABLE(flags, bug, reason) __pragma(optimize(flags, off)) |
|
#define | BEGIN_PRAGMA_OPTIMIZE_ENABLE(flags, bug, reason) __pragma(optimize(flags, on)) |
|
#define | END_PRAGMA_OPTIMIZE() __pragma(optimize("", on)) |
|
#define | __fileDECL __cdecl |
|
#define | __COMPARE(context, p1, p2) comp(p1, p2) |
|
#define | __SHORTSORT(lo, hi, width, comp, context) shortsort(lo, hi, width, comp); |
|
#define | _QSORT_SWAP_DEFINED |
|
#define | CUTOFF 8 |
|
#define | STKSIZ (8 * sizeof(void*) - 2) |
|
|
static _CRT_SECURITYSAFECRITICAL_ATTRIBUTE void __fileDECL | swap (_Inout_updates_(width) char *a, _Inout_updates_(width) char *b, size_t width) |
|
static _CRT_SECURITYSAFECRITICAL_ATTRIBUTE void __fileDECL | shortsort (_Inout_updates_(hi - lo+1) char *lo, _Inout_updates_(width) char *hi, size_t const width, int(__fileDECL *comp)(void const *, void const *)) |
|
_CRT_SECURITYSAFECRITICAL_ATTRIBUTE void __fileDECL | qsort (void *const base, size_t const num, size_t const width, int(__fileDECL *const comp)(void const *, void const *)) |
|
◆ __COMPARE
◆ __fileDECL
◆ __SHORTSORT
◆ _QSORT_SWAP_DEFINED
◆ BEGIN_PRAGMA_OPTIMIZE_DISABLE
◆ BEGIN_PRAGMA_OPTIMIZE_ENABLE
◆ CUTOFF
◆ END_PRAGMA_OPTIMIZE
◆ STKSIZ
◆ qsort()
Definition at line 164 of file qsort.cpp.
171{
175
176
179 int stkptr = 0;
180
182 return;
183
184
185
186 char* lo =
static_cast<char*
>(
base);
188
189
190
191
192recurse:
193
194
195 size_t const size = (hi - lo) /
width + 1;
196
197
199 {
201 }
202 else
203 {
204
205
206
207
208
209
210
211
212
213
215
216
219
222
225
226
227
228
229
230
231 char* loguy = lo;
232 char* higuy = hi;
233
234
235
236 for (;;)
237 {
238
239
240
241
242
243
244
245
246
247 if (mid > loguy)
248 {
249 do
250 {
252 }
254 }
255 if (mid <= loguy)
256 {
257 do
258 {
260 }
262 }
263
264
265
266
267 do
268 {
270 }
272
273
274
275
276 if (higuy < loguy)
277 break;
278
279
280
281
282
284
285
286
287
288
289 if (mid == higuy)
290 mid = loguy;
291
292
293
294 }
295
296
297
298
299
300
301
302
303
304
305
306
307
308
310 if (mid < higuy)
311 {
312 do
313 {
315 }
317 }
318 if (mid >= higuy)
319 {
320 do
321 {
323 }
325 }
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340 if (higuy - lo >= hi - loguy)
341 {
342 if (lo < higuy)
343 {
344
345 lostk[stkptr] = lo;
346 histk[stkptr] = higuy;
347 ++stkptr;
348 }
349
350 if (loguy < hi)
351 {
352
353 lo = loguy;
354 goto recurse;
355 }
356 }
357 else
358 {
359 if (loguy < hi)
360 {
361
362 lostk[stkptr] = loguy;
363 histk[stkptr] = hi;
364 ++stkptr;
365 }
366
367 if (lo < higuy)
368 {
369
370 hi = higuy;
371 goto recurse;
372 }
373 }
374 }
375
376
377
378 --stkptr;
379 if (stkptr >= 0)
380 {
381
382 lo = lostk[stkptr];
383 hi = histk[stkptr];
384 goto recurse;
385 }
386 else
387 {
388
389 return;
390 }
391}
#define _VALIDATE_RETURN_VOID(expr, errorcode)
GLint GLint GLsizei width
#define __SHORTSORT(lo, hi, width, comp, context)
#define __COMPARE(context, p1, p2)
◆ shortsort()
Definition at line 83 of file qsort.cpp.
90{
91
92
93
94
95 __crt_state_management::scoped_global_state_reset saved_state;
96
97 while (hi > lo)
98 {
99
102 {
103
105 {
107 }
108
109 }
110
111
112
114
115
116
118
119
120 }
121
122
123
124}
◆ swap()
Definition at line 50 of file qsort.cpp.
51{
53 {
54
55
57 {
61 }
62 }
63}
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a