You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I propose to make the following framework for custom "item comparators", and to implement built-in functionality on top of it.
Low-level API allows user to choose how many buckets are used on each pass:
template<classLowLevelCustomComparator>classLowLevelSorter {...} // Here we should perform all the real work!template<typenameT>classLowLevelCustomComparator
{
// Total number of radix-sort passes over data or 0 for variable amountstaticintpasses;
// How many buckets to use on this passtemplate<intpass>staticintbuckets();
// Compute bucket from the itemtemplate<intpass>staticintbucket (Titem);
// Bucket used for items that don't need any more sorting, i.e. 0 for stringstemplate<intpass>staticintfinal_bucket();
}
High-level API just tells how many bits in the sort key. Library provides implementation of this API that calls into the low-level API using optimal (for this particular box) settings for each pass:
template<classHighLevelCustomComparator>classHighLevelSorter {...}
template<typenameT>classHighLevelCustomComparator
{
// Total number of bits in the key or 0 for variable amountstaticintbits;
// Compute bucket from the item for some passtemplate<intfirst_bit, intlast_bit>staticintbucket (Titem);
// Bucket used for items that don't need any more sorting, i.e. 0 for stringstemplate<intfirst_bit, intlast_bit>staticintfinal_bucket();
}
Finally, highest-level code should implement standard sorting of standard C++ types by constructing HighLevelCustomComparator from the type and provide user with tools to construct comparator f.e. for selected fields in the structure.
The text was updated successfully, but these errors were encountered:
Bulat-Ziganshin
changed the title
Framework for custom "item compare" functions
Framework for custom "item comparators"
Jul 2, 2018
I propose to make the following framework for custom "item comparators", and to implement built-in functionality on top of it.
Low-level API allows user to choose how many buckets are used on each pass:
High-level API just tells how many bits in the sort key. Library provides implementation of this API that calls into the low-level API using optimal (for this particular box) settings for each pass:
Finally, highest-level code should implement standard sorting of standard C++ types by constructing HighLevelCustomComparator from the type and provide user with tools to construct comparator f.e. for selected fields in the structure.
The text was updated successfully, but these errors were encountered: