MCPcopy Create free account
hub / github.com/numpy/numpy / mergesort0_

Function mergesort0_

numpy/core/src/npysort/mergesort.cpp:50–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48
49template <typename Tag, typename type>
50static void
51mergesort0_(type *pl, type *pr, type *pw)
52{
53 type vp, *pi, *pj, *pk, *pm;
54
55 if (pr - pl > SMALL_MERGESORT) {
56 /* merge sort */
57 pm = pl + ((pr - pl) >> 1);
58 mergesort0_<Tag>(pl, pm, pw);
59 mergesort0_<Tag>(pm, pr, pw);
60 for (pi = pw, pj = pl; pj < pm;) {
61 *pi++ = *pj++;
62 }
63 pi = pw + (pm - pl);
64 pj = pw;
65 pk = pl;
66 while (pj < pi && pm < pr) {
67 if (Tag::less(*pm, *pj)) {
68 *pk++ = *pm++;
69 }
70 else {
71 *pk++ = *pj++;
72 }
73 }
74 while (pj < pi) {
75 *pk++ = *pj++;
76 }
77 }
78 else {
79 /* insertion sort */
80 for (pi = pl + 1; pi < pr; ++pi) {
81 vp = *pi;
82 pj = pi;
83 pk = pi - 1;
84 while (pj > pl && Tag::less(vp, *pk)) {
85 *pj-- = *pk--;
86 }
87 *pj = vp;
88 }
89 }
90}
91
92template <typename Tag, typename type>
93NPY_NO_EXPORT int

Callers

nothing calls this directly

Calls 2

lessFunction · 0.50
copyFunction · 0.50

Tested by

no test coverage detected