Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb_ska_sort::detail::UnsignedInplaceSorter< StdSortThreshold, AmericanFlagSortThreshold, CurrentSubKey, NumBytes, Offset > Struct Template Reference

Static Public Member Functions

template<typename T>
static uint8_t current_byte (T &&elem, void *sort_data)
template<typename It, typename ExtractKey>
static void sort (It begin, It end, size_t num_elements, ExtractKey &extract_key, void(*next_sort)(It, It, size_t, ExtractKey &, void *), void *sort_data)
template<typename It, typename ExtractKey>
static void american_flag_sort (It begin, It end, ExtractKey &extract_key, void(*next_sort)(It, It, size_t, ExtractKey &, void *), void *sort_data)
template<typename It, typename ExtractKey>
static void ska_byte_sort (It begin, It end, ExtractKey &extract_key, void(*next_sort)(It, It, size_t, ExtractKey &, void *), void *sort_data)

Static Public Attributes

static constexpr size_t ShiftAmount = (((NumBytes - 1) - Offset) * 8)

Member Function Documentation

◆ current_byte()

template<size_t StdSortThreshold, size_t AmericanFlagSortThreshold, typename CurrentSubKey, size_t NumBytes, size_t Offset = 0>
template<typename T>
uint8_t duckdb_ska_sort::detail::UnsignedInplaceSorter< StdSortThreshold, AmericanFlagSortThreshold, CurrentSubKey, NumBytes, Offset >::current_byte ( T && elem,
void * sort_data )
inlinestatic
106176 {
106177 return static_cast<uint8_t>(CurrentSubKey::sub_key(elem, sort_data) >> ShiftAmount);
106178 }

◆ sort()

template<size_t StdSortThreshold, size_t AmericanFlagSortThreshold, typename CurrentSubKey, size_t NumBytes, size_t Offset = 0>
template<typename It, typename ExtractKey>
void duckdb_ska_sort::detail::UnsignedInplaceSorter< StdSortThreshold, AmericanFlagSortThreshold, CurrentSubKey, NumBytes, Offset >::sort ( It begin,
It end,
size_t num_elements,
ExtractKey & extract_key,
void(* next_sort )(It, It, size_t, ExtractKey &, void *),
void * sort_data )
inlinestatic
106181 {
106182 if (extract_key.Interrupted())
106183 return;
106184 else if (extract_key.ByteIsSkippable(Offset))
106187 american_flag_sort(begin, end, extract_key, next_sort, sort_data);
106188 else
106189 ska_byte_sort(begin, end, extract_key, next_sort, sort_data);
106190 }

◆ american_flag_sort()

template<size_t StdSortThreshold, size_t AmericanFlagSortThreshold, typename CurrentSubKey, size_t NumBytes, size_t Offset = 0>
template<typename It, typename ExtractKey>
void duckdb_ska_sort::detail::UnsignedInplaceSorter< StdSortThreshold, AmericanFlagSortThreshold, CurrentSubKey, NumBytes, Offset >::american_flag_sort ( It begin,
It end,
ExtractKey & extract_key,
void(* next_sort )(It, It, size_t, ExtractKey &, void *),
void * sort_data )
inlinestatic
106194 {
106196 for (It it = begin; it != end; ++it)
106197 {
106198 ++partitions[current_byte(extract_key(*it), sort_data)].count;
106199 }
106200 size_t total = 0;
106202 int num_partitions = 0;
106203 for (int i = 0; i < 256; ++i)
106204 {
106205 size_t count = partitions[i].count;
106206 if (!count)
106207 continue;
106208 partitions[i].offset = total;
106209 total += count;
106210 partitions[i].next_offset = total;
106211 remaining_partitions[num_partitions] = static_cast<uint8_t>(i);
106212 ++num_partitions;
106213 }
106214 if (num_partitions > 1)
106215 {
106219 It it = begin;
106220 It block_end = begin + current_block->next_offset;
106221 It last_element = end - 1;
106222 for (;;)
106223 {
106224 PartitionInfo * block = partitions + current_byte(extract_key(*it), sort_data);
106225 if (block == current_block)
106226 {
106227 ++it;
106228 if (it == last_element)
106229 break;
106230 else if (it == block_end)
106231 {
106232 for (;;)
106233 {
106236 goto recurse;
106238 if (current_block->offset != current_block->next_offset)
106239 break;
106240 }
106241
106242 it = begin + current_block->offset;
106243 block_end = begin + current_block->next_offset;
106244 }
106245 }
106246 else
106247 {
106248 size_t offset = block->offset++;
106250 }
106251 }
106252 }
106253 recurse:
106254 if (Offset + 1 != extract_key.ska_sort_width || next_sort)
106255 {
106256 size_t start_offset = 0;
106259 {
106260 size_t end_offset = partitions[*it].next_offset;
106264 {
106266 }
106269 }
106270 }
106271 }

◆ ska_byte_sort()

template<size_t StdSortThreshold, size_t AmericanFlagSortThreshold, typename CurrentSubKey, size_t NumBytes, size_t Offset = 0>
template<typename It, typename ExtractKey>
void duckdb_ska_sort::detail::UnsignedInplaceSorter< StdSortThreshold, AmericanFlagSortThreshold, CurrentSubKey, NumBytes, Offset >::ska_byte_sort ( It begin,
It end,
ExtractKey & extract_key,
void(* next_sort )(It, It, size_t, ExtractKey &, void *),
void * sort_data )
inlinestatic
106275 {
106277 for (It it = begin; it != end; ++it)
106278 {
106279 ++partitions[current_byte(extract_key(*it), sort_data)].count;
106280 }
106282 size_t total = 0;
106283 int num_partitions = 0;
106284 for (int i = 0; i < 256; ++i)
106285 {
106286 size_t count = partitions[i].count;
106287 if (count)
106288 {
106289 partitions[i].offset = total;
106290 total += count;
106291 remaining_partitions[num_partitions] = static_cast<uint8_t>(i);
106292 ++num_partitions;
106293 }
106294 partitions[i].next_offset = total;
106295 }
106297 {
106299 {
106300 size_t & begin_offset = partitions[partition].offset;
106301 size_t & end_offset = partitions[partition].next_offset;
106302 if (begin_offset == end_offset)
106303 return false;
106304
106307 {
106308 uint8_t this_partition = current_byte(extract_key(*it), sort_data);
106309 size_t offset = partitions_copy[this_partition].offset++;
106311 });
106312 return begin_offset != end_offset;
106313 });
106314 }
106315 if (Offset + 1 != extract_key.ska_sort_width || next_sort)
106316 {
106318 {
106319 uint8_t partition = it[-1];
106320 size_t start_offset = (partition == 0 ? 0 : partitions[partition - 1].next_offset);
106321 size_t end_offset = partitions[partition].next_offset;
106326 {
106328 }
106329 }
106330 }
106331 }

The documentation for this struct was generated from the following file: