| 1 | /* |
| 2 | Copyright (C) 2024 Abe Tomoaki <[email protected]> |
| 3 | |
| 4 | This library is free software; you can redistribute it and/or |
| 5 | modify it under the terms of the GNU Lesser General Public |
| 6 | License as published by the Free Software Foundation; either |
| 7 | version 2.1 of the License, or (at your option) any later version. |
| 8 | |
| 9 | This library 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 GNU |
| 12 | Lesser General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU Lesser General Public |
| 15 | License along with this library; if not, write to the Free Software |
| 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | */ |
| 18 | |
| 19 | #include "grn.h"cxx . . $ `<file>/lib/grn.h`/ |
| 20 | #include "grn_portability.h"cxx . . $ `<file>/lib/grn_portability.h`/ |
| 21 | |
| 22 | #include <algorithm> |
| 23 | |
| 24 | extern "C" { |
| 25 | |
| 26 | /* todo: Implement the general grn_qsort_r() that takes `base` as `void *`. */ |
| 27 | void |
| 28 | grn_qsort_r_grn_id(grn_id *base, |
| 29 | size_t n_members, |
| 30 | int (*compare)(const grn_id id1, |
| 31 | const grn_id id2, |
| 32 | void *arg), |
| 33 | void *arg) |
| 34 | { |
| 35 | stdcxx . . $ std/::sortcxx . . $ std/sort(4d3091562df4e52e).(base, |
| 36 | base + n_members, |
| 37 | [&compare, &arg](const grn_id id1, const grn_id id2) { |
| 38 | return compare(id1, id2, arg) < 0; |
| 39 | }); |
| 40 | } |
| 41 | } |