| 41 | |
| 42 | |
| 43 | static void reverse(void *first, void *last, size_t size) { |
| 44 | ALGORITHM_LOG("[reverse] Reversing elements between memory locations %p and %p, each of size %zu bytes.", first, last, size); |
| 45 | |
| 46 | char *a = (char *)first; |
| 47 | char *b = (char *)last - size; |
| 48 | |
| 49 | while (a < b) { |
| 50 | ALGORITHM_LOG("[reverse] Swapping elements at positions %p and %p.", a, b); |
| 51 | swap(a, b, size); |
| 52 | a += size; |
| 53 | b -= size; |
| 54 | } |
| 55 | |
| 56 | ALGORITHM_LOG("[reverse] Completed reversing elements."); |
| 57 | } |
| 58 | |
| 59 | |
| 60 | #define SRT_ISORT_MAX 16 /* ranges this small are insertion-sorted */ |
no test coverage detected