Skip to main content

sparse_intersection_count

Function sparse_intersection_count 

Source
pub fn sparse_intersection_count(a: &[u32], b: &[u32]) -> usize
Expand description

Count common elements in two sorted u32 slices.

Adaptively picks the best algorithm:

  • When one slice is much smaller (|a| * 8 < |b|), uses galloping search which is O(|small| * log(|large|)) and beats O(|a| + |b|) merge.
  • Otherwise uses the standard sorted merge at O(|a| + |b|).