Skip to content

Engine → Core

radix_sort.h

Stable least-significant-digit radix sort for unsigned keys with optional 32-bit payloads.

Functions

Public

radix_sort_u32

CONJURE_API void radix_sort_u32(
    std::span<u32> keys,
    std::span<u32> values,
    std::span<u32> scratchKeys,
    std::span<u32> scratchValues) noexcept;

32-bit variant of radix_sort_u64 with payloads: four passes at most.

CONJURE_API void radix_sort_u32(
    std::span<u32> keys,
    std::span<u32> scratchKeys) noexcept;

32-bit variant of radix_sort_u64 for keys only.

radix_sort_u64

CONJURE_API void radix_sort_u64(
    std::span<u64> keys,
    std::span<u32> values,
    std::span<u64> scratchKeys,
    std::span<u32> scratchValues) noexcept;

Sorts keys ascending and permutes values alongside them. Stable. values must have the same size as keys, both scratch spans must be at least that large and no two of the four spans may overlap (all asserted; the input is left untouched on violation). On return the sorted data is in keys/values; the scratch contents are unspecified.

CONJURE_API void radix_sort_u64(
    std::span<u64> keys,
    std::span<u64> scratchKeys) noexcept;

Sorts keys ascending. Stable. scratchKeys must be at least as large as keys and must not overlap it.