Skip to main content

is_subset

Function is_subset 

Source
pub fn is_subset<const ALLOW_EMPTY: bool>(
    super_set: impl Iterator<Item = Range>,
    sub_set: impl Iterator<Item = Range>,
) -> bool
Expand description

Returns true if all ranges yielded by sub_set are contained by super_set. This is essentially an optimized implementation of sub_set.all(|rb| super_set.any(|ra| ra.contains(rb))) that runs in O(m+n) instead of O(mn) (and in many cases faster).

Both iterators must uphold a the following invariants:

  • ranges must not overlap (but they can be adjacent)
  • ranges must be sorted