Skip to main content

CCHManyToOne

Struct CCHManyToOne 

Source
pub struct CCHManyToOne<'a> { /* private fields */ }
Expand description

A reusable many-to-one query with a fixed (pinned) set of sources.

The mirror image of CCHOneToMany: pinning precomputes the search space of the sources once; each CCHManyToOne::distances_to call answers distances from all pinned sources to a target in a single sweep.

Thread-safety: Send but not Sync; holds mutable per-query state.

Implementations§

Source§

impl<'a> CCHManyToOne<'a>

Source

pub fn new(metric: &'a CCHMetric<'a>, sources: &[u32]) -> Self

Create a many-to-one query bound to metric with a fixed set of pinned sources. Distances returned later are aligned with the order of sources (duplicates are allowed and answered per entry).

Panics if any source node id is out of range.

Source

pub fn source_count(&self) -> usize

Number of pinned sources (= length of the distance vectors returned).

Source

pub fn repin_sources(&mut self, sources: &[u32])

Replace the pinned source set, reusing the query’s internal O(n) label buffers (cheaper than constructing a new CCHManyToOne).

Panics if any source node id is out of range.

Source

pub fn distances_to(&mut self, target: u32) -> Vec<Option<u32>>

Compute the shortest distances from every pinned source to target. Result is aligned with the pinned source order; None = unreachable.

Source

pub fn distances_to_multi(&mut self, targets: &[(u32, u32)]) -> Vec<Option<u32>>

Multi-target variant: for each pinned source s, returns min over the given (target, initial_dist) pairs of dist(s, target) + initial_dist.

Panics if targets is empty or contains node ids out of range.

Auto Trait Implementations§

§

impl<'a> !Sync for CCHManyToOne<'a>

§

impl<'a> Freeze for CCHManyToOne<'a>

§

impl<'a> RefUnwindSafe for CCHManyToOne<'a>

§

impl<'a> Send for CCHManyToOne<'a>

§

impl<'a> Unpin for CCHManyToOne<'a>

§

impl<'a> UnsafeUnpin for CCHManyToOne<'a>

§

impl<'a> UnwindSafe for CCHManyToOne<'a>

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> 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, 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.