[−][src]Struct cjdns_snode::pathsearch::frontier::Frontier
Frontier for the Dijkstra algorithm. Internally uses binary search to maintain priority queue and hashmap-based index.
Fields
queue: Vec<(T, W)>
Stores items in cost-descending order, so the item with the lowest cost is placed at the end of the array.
index: HashMap<T, usize>
Links node tag <T>
to the index in the queue
.
Implementations
impl<T, W> Frontier<T, W> where
T: Clone + Ord + Eq + Hash,
W: Clone + PartialOrd + IntoOrd,
[src]
T: Clone + Ord + Eq + Hash,
W: Clone + PartialOrd + IntoOrd,
pub fn new() -> Frontier<T, W>
[src]
Create new empty instance.
fn key_fn(item: &(T, W)) -> impl Ord
[src]
Sorts by cost in descending order, then by tag.
fn insertion_pos(&self, item: &(T, W)) -> usize
[src]
Find position in the queue where to insert a new item.
pub fn push(&mut self, tag: T, weight: W)
[src]
Insert a node with associated cost into the priority queue.
pub fn pop(&mut self) -> Option<(T, W)>
[src]
Extract node with the least cost from the queue.
pub fn try_insert_or_decrease_cost(&mut self, tag: &T, new_cost: W) -> bool
[src]
Insert a node if it is not in the queue yet,
otherwise update associated cost if the new cost is less that existing.
Returns true
if the node was either inserted or updated,
otherwise (node existed and current cost is less that the new one) false
.
Auto Trait Implementations
impl<T, W> RefUnwindSafe for Frontier<T, W> where
T: RefUnwindSafe,
W: RefUnwindSafe,
T: RefUnwindSafe,
W: RefUnwindSafe,
impl<T, W> Send for Frontier<T, W> where
T: Send,
W: Send,
T: Send,
W: Send,
impl<T, W> Sync for Frontier<T, W> where
T: Sync,
W: Sync,
T: Sync,
W: Sync,
impl<T, W> Unpin for Frontier<T, W> where
T: Unpin,
W: Unpin,
T: Unpin,
W: Unpin,
impl<T, W> UnwindSafe for Frontier<T, W> where
T: UnwindSafe,
W: UnwindSafe,
T: UnwindSafe,
W: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,