Skip to main content

U64COSet

Struct U64COSet 

Source
pub struct U64COSet { /* private fields */ }
Expand description

Immutable canonical interval set.

Internally this is an Arc<[U64CO]>, so cloning a U64COSet is cheap.

Canonical invariant:

for every adjacent pair a, b:
    a.end_excl() < b.start()

The strict < means both overlap and adjacency have already been merged.

Implementations§

Source§

impl U64COSet

Source

pub fn interval_count(&self) -> u64

Returns the number of canonical intervals.

For the U64CO domain, the maximum canonical interval count is 128, e.g. [0, 1), [2, 3), ..., [254, 255).

Source

pub fn is_empty(&self) -> bool

Returns whether the set contains no intervals.

Source

pub fn as_slice(&self) -> &[U64CO]

Returns the canonical interval slice.

The returned slice is sorted, non-overlapping, and contains no adjacent intervals.

Source

pub fn iter_intervals(&self) -> impl Iterator<Item = U64CO>

Iterates over canonical intervals by value.

Source§

impl U64COSet

Source

pub fn contains_point(&self, x: u64) -> bool

Returns whether x is covered by any interval in the set.

Complexity: O(log n).

Source

pub fn contains_interval(&self, query: U64CO) -> bool

Returns whether query is fully contained by one interval.

Since the set is canonical, a contained query interval can only be contained by the interval immediately preceding or starting at query.start().

Complexity: O(log n).

Source

pub fn intersects_interval(&self, query: U64CO) -> bool

Returns whether query intersects any interval in the set.

Complexity: O(log n).

Source§

impl U64COSet

Source

pub fn interval_containing_point(&self, x: u64) -> Option<U64CO>

Returns the unique interval containing x, if any.

Because the set is canonical, at most one interval can contain a single point.

Complexity: O(log n).

Source§

impl U64COSet

Source

pub fn intervals_intersecting( &self, query: U64CO, ) -> impl Iterator<Item = U64CO>

Iterates over all canonical intervals intersecting query.

The iterator yields original intervals stored in the set, not clipped intersection segments.

Complexity: O(log n + k), where k is the number of returned intervals.

Source

pub fn intersections(&self, query: U64CO) -> impl Iterator<Item = U64CO>

Iterates over clipped intersection segments with query.

Example:

set:   [10, 20), [30, 40)
query: [15, 35)
out:   [15, 20), [30, 35)

Complexity: O(log n + k), where k is the number of intersecting intervals.

Source§

impl U64COSet

Source

pub fn covered_len(&self, query: U64CO) -> u64

Returns the covered length inside query.

Since U64COSet is canonical, all intersection segments are disjoint, so summing their lengths is valid.

The result is always <= query.len().

Source

pub fn uncovered_len(&self, query: U64CO) -> u64

Returns the uncovered length inside query.

Source

pub fn coverage_ratio(&self, query: U64CO) -> f32

Returns covered_len(query) / query.len() as f32.

query.len() is non-zero because U64CO cannot represent an empty interval.

Trait Implementations§

Source§

impl Clone for U64COSet

Source§

fn clone(&self) -> U64COSet

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for U64COSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for U64COSet

Source§

fn eq(&self, other: &U64COSet) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for U64COSet

Source§

impl StructuralPartialEq for U64COSet

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.