Skip to content

Commit 20729e8

Browse files
Document the 2^32 - 1 element limit of the counting and radix sorts
1 parent 126ffc9 commit 20729e8

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

libs/libvtrutil/src/vtr_sort.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ namespace vtr {
3535
* than the element count) wastes both time and memory on empty counts, so
3636
* such inputs are a poor match for this function.
3737
*
38+
* The input may hold at most 2^32 - 1 elements. Output positions are stored
39+
* as uint32_t to halve the memory traffic of the counts array, which is
40+
* accessed randomly in the placement pass.
41+
*
3842
* @tparam InIt Forward iterator over the input elements.
3943
* @tparam OutIt Random access iterator to the output range.
4044
* @tparam KeyFn Callable mapping an element to its key. The key may be any
@@ -138,6 +142,7 @@ void stable_radix_sort_passes(Container& items, Container& scratch, const KeyTup
138142
* std::stable_sort by the tuple of keys, but it is computed as one stable
139143
* counting sort pass per key, least significant key first. The input is read
140144
* directly, so a generated sequence such as a vtr::StrongIdRange needs no copy first.
145+
* As with stable_counting_sort, the input may hold at most 2^32 - 1 elements.
141146
*
142147
* Example, sorting edges by (source node, destination node):
143148
*

0 commit comments

Comments
 (0)