2 * Copyright (C) 2013 Andrea Mazzoleni
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
17 #define RAID_SWAP(a, b) \
26 void raid_sort(int n, int *v)
28 /* sorting networks generated with Batcher's Merge-Exchange */
73 void raid_insert(int n, int *v, int i)
75 /* we don't use binary search because this is intended */
76 /* for very small vectors and we want to optimize the case */
77 /* of elements inserted already in order */
79 /* insert at the end */
82 /* swap until in the correct position */
83 while (n > 0 && v[n - 1] > v[n]) {
90 /* previous position */