26#define INSERTION_SORT_THRESHOLD 16
41 for (
sint i = low + 1; i <= high; ++i) {
45 while (j >= low && arr[j].nn > nn) {
46 arr[j + 1].
np = arr[j].
np;
47 arr[j + 1].
nn = arr[j].
nn;
86 sint mid = low + (high - low) / 2;
88 if (pivot_index != low) {
98 if (arr[i].nn < pivot) {
102 }
else if (arr[i].nn > pivot) {
128 while (
k < (2 *
n - 1)) {
131 if (i <
n && (j >=
k || arr[i].nn <= arr[j].nn)) {
137 if (i <
n && (j >=
k || arr[i].nn <= arr[j].nn)) {
144 arr[
k].
nn = arr[idx1].
nn + arr[idx2].
nn;
154 if (ht->root[ridx].left == -1) {
155 lmmp_copy(dst, ht->root[ridx].np, ht->root[ridx].nn);
156 return ht->root[ridx].nn;
158 sint idx = ht->root[ridx].left;
167 n1 -= dst[n1 - 1] == 0 ? 1 : 0;
180 rn -= dst[rn - 1] == 0 ? 1 : 0;
192 n -= dst[
n - 1] == 0 ? 1 : 0;
#define INSERTION_SORT_THRESHOLD
Copyright (C) 2026 HJimmyK (Jericho Knox)
mp_size_t lmmp_huff_tree_mul_(huff_tree *restrict ht, sint ridx, mp_ptr restrict dst, mp_ptr restrict tp)
sint lmmp_huff_tree_build_(huff_tree *restrict ht)
static void insertion_sort(huff_node arr[], sint low, sint high)
在闭区间 [low, high] 上进行插入排序
static void quicksort_rec(huff_node arr[], sint low, sint high)
递归的三路快速排序,对闭区间 [low, high] 排序
static sint median_of_three(const huff_node arr[], sint a, sint b, sint c)
返回 arr[a]、arr[b]、arr[c] 三个索引中对应值的中位数的索引
mp_size_t lmmp_elem_mul_ulong_(mp_ptr restrict dst, const ulongp restrict limbs, mp_size_t n, mp_ptr restrict tp)
static void swap_huff_node(huff_node *a, huff_node *b)
Copyright (C) 2026 HJimmyK (Jericho Knox)
#define lmmp_copy(dst, src, n)
const mp_limb_t * mp_srcptr
#define lmmp_param_assert(x)
void lmmp_mul_(mp_ptr dst, mp_srcptr numa, mp_size_t na, mp_srcptr numb, mp_size_t nb)
不等长乘法操作 [dst,na+nb] = [numa,na] * [numb,nb]
mp_limb_t lmmp_mul_1_(mp_ptr dst, mp_srcptr numa, mp_size_t na, mp_limb_t x)
乘以单limb操作 [dst,na] = [numa,na] * x
#define ELEM_MUL_BASECASE_THRESHOLD
#define restrict
Copyright (C) 2026 HJimmyK (Jericho Knox)