Compact native frontend scans #
Each pass reads both canonical keys and their full multiplicities. It appends only selected keys to a disjoint destination. The singleton-zero arrays are written separately, so empty input needs no exceptional semantics.
Main definitions #
Scan.program: charged compact selection from the radix output.
Key pointer, count pointer and number of distinct keys.
Key pointer, count pointer and number of distinct keys.
Key pointer, count pointer and number of distinct keys.
Output pointer, input cursor and output length.
Output pointer, input cursor and output length.
Output pointer, input cursor and output length.
Address scratch.
Load one full key/count pair, compute its selection, optionally append, and advance.
Reset both cursors and scan all distinct keys.
One charged compacting iteration.
Complete compact scan, with arbitrary old output/scratch memory and an exact memory frame. The source key/count blocks precede the output; their contents and all caller registers that the body does not write are retained.