pub fn stream_compaction<T: Clone>(
data: &[T],
pred: impl Fn(&T) -> bool,
) -> (Vec<T>, Vec<usize>)Expand description
Stream compaction: retain only elements satisfying a predicate, returning a compacted output together with a scatter index map.
Returns (compacted, scatter_map) where:
compactedcontains the elementsdata[i]for whichpred(data[i])is true.scatter_map[j]is the original indexiofcompacted[j].
This mirrors a GPU stream-compaction pass (prefix-sum → scatter).