use rustsy_compute::{ReportOnExit, ordered_subset};
fn exercise(source: &[u64], target: &[u64]) {
let cpu_scan = || {
let mut incoming = target.iter();
source.iter().all(|key| incoming.any(|other| key == other))
};
assert_eq!(
ordered_subset(source, target, |key| key, cpu_scan),
cpu_scan()
);
}
fn main() {
let _report = ReportOnExit;
exercise(&[2, 1], &[2, 4, 1]);
exercise(&[1, 2], &[2, 4, 1]);
exercise(&[9, 1], &[2, 4, 1]);
exercise(&[4, 4], &[4, 5, 4]);
exercise(&[4, 4], &[4, 5, 6]);
exercise(&[], &[4]);
exercise(&[1 << 48], &[1 << 48, 4]);
let target: Vec<_> = (1..4096).map(|i| (i * 3_227u64) % 4_096).collect();
let source: Vec<_> = target.iter().step_by(3).copied().collect();
exercise(&source, &target);
exercise(&source.iter().rev().copied().collect::<Vec<_>>(), &target);
}