Skip to documentation
SLOP

tiny.simd.countingSort

Reference tiny.simd countingSort

Defined in robust.

Called byCallsrobustcountingSortArrayrobustmodetest sourcelib.simd.src.robusttest: Highway robust counting sort or...robustCountingSortEntryprivate sourcelib.simd.src.robustEntryAscendingprivate sourcelib.simd.src.robustrequireIntegerrobustcountingSort
Static calls · unresolved targets: 0 · external targets: 0.

Source

Source: lib/simd/src/robust.zig:14

zig
pub fn countingSort(    comptime T: type,    values: []T,    scratch: []CountingSortEntry(T),) Error!void {    comptime requireInteger(T);    const Entry = CountingSortEntry(T);    var unique_count: usize = 0;    for (values) |value| {        var unique_index: usize = 0;        while (unique_index < unique_count and scratch[unique_index].value != value) {            unique_index += 1;        }        if (unique_index == unique_count) {            if (unique_count == scratch.len) return error.InsufficientScratch;            scratch[unique_count] = .{ .value = value, .count = 1 };            unique_count += 1;        } else {            scratch[unique_index].count += 1;        }    }    std.mem.sort(Entry, scratch[0..unique_count], {}, EntryAscending(Entry).lessThan);    var output_index: usize = 0;    for (scratch[0..unique_count]) |entry| {        const end = output_index + entry.count;        @memset(values[output_index..end], entry.value);        output_index = end;    }    std.debug.assert(output_index == values.len);}

Source: lib/simd/src/root.zig:547

zig
pub const countingSort = robust.countingSort;

Audit

Definitions1
Public names2
Members0
Version26.7.0
Revisiondaab053ee433