[][src]Struct cjdns_snode::pathsearch::frontier::Frontier

pub(super) struct Frontier<T, W> {
    queue: Vec<(T, W)>,
    index: HashMap<T, usize>,
}

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]

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

impl<T, W> Send for Frontier<T, W> where
    T: Send,
    W: Send

impl<T, W> Sync for Frontier<T, W> where
    T: Sync,
    W: Sync

impl<T, W> Unpin for Frontier<T, W> where
    T: Unpin,
    W: Unpin

impl<T, W> UnwindSafe for Frontier<T, W> where
    T: UnwindSafe,
    W: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,