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

Function merge_right_

numpy/core/src/npysort/timsort.cpp:222–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220 */
221template <typename Tag, typename type>
222static void
223merge_right_(type *p1, npy_intp l1, type *p2, npy_intp l2, type *p3)
224{
225 npy_intp ofs;
226 type *start = p1 - 1;
227 memcpy(p3, p2, sizeof(type) * l2);
228 p1 += l1 - 1;
229 p2 += l2 - 1;
230 p3 += l2 - 1;
231 /* first element must be in p1 otherwise skipped in the caller */
232 *p2-- = *p1--;
233
234 while (p1 < p2 && start < p1) {
235 if (Tag::less(*p3, *p1)) {
236 *p2-- = *p1--;
237 }
238 else {
239 *p2-- = *p3--;
240 }
241 }
242
243 if (p1 != p2) {
244 ofs = p2 - start;
245 memcpy(start + 1, p3 - ofs + 1, sizeof(type) * ofs);
246 }
247}
248
249/* Note: the naming convention of gallop functions are different from that of
250 * CPython. For example, here gallop_right means gallop from left toward right,

Callers

nothing calls this directly

Calls 2

lessFunction · 0.50
copyFunction · 0.50

Tested by

no test coverage detected