11#ifndef GADGET4_CXXSORT_H
12#define GADGET4_CXXSORT_H
16#include "../data/allvars.h"
17#include "../data/mymalloc.h"
18#include "../logs/logs.h"
20template <
typename T,
typename Tcomp>
23 std::size_t n = end - begin;
26 if((n == 1) && res_into_buf)
34 res_into_buf ? std::merge(begin, begin + n / 2, begin + n / 2, begin + n, buf, comp)
35 : std::merge(buf, buf + n / 2, buf + n / 2, buf + n, begin, comp);
38template <
typename T,
typename Tcomp>
46 T *buf = (T *)
Mem.mymalloc(
"buf", (end - begin) *
sizeof(T));
double timediff(double t0, double t1)
double mycxxsort(T *begin, T *end, Tcomp comp)
void mycxxsort_internal_serial(T *begin, T *end, T *buf, bool res_into_buf, Tcomp comp)