#ifndef MERGESORT_H #define MERGESORT_H /* Combine two sorted lists. Take from `list` on equality. */ #define DEFINE_LIST_MERGE_INTERNAL(name, type) … /* * Perform an iterative mergesort using an array of sublists. * * n is the number of items. * ranks[i] is undefined if n & 2^i == 0, and assumed empty. * ranks[i] contains a sublist of length 2^i otherwise. * * The number of bits in a void pointer limits the number of objects * that can be created, and thus the number of array elements necessary * to be able to sort any valid list. * * Adding an item to this array is like incrementing a binary number; * positional values for set bits correspond to sublist lengths. */ #define DEFINE_LIST_SORT_INTERNAL(scope, name, type) … #define DECLARE_LIST_SORT(scope, name, type) … #define DEFINE_LIST_SORT_DEBUG(scope, name, type, next_member, \ on_get_next, on_set_next) … #define DEFINE_LIST_SORT(scope, name, type, next_member) … #endif