Trait orx_priority_queue::HasIndex

source ·
pub trait HasIndex: Clone {
    // Required method
    fn index(&self) -> usize;
}
Expand description

A struct which provides an index of type usize. Index of the struct can be considered its unchanging id defined its position in a collection.

For instance consider a tour generation problem for cities in the collection {X, Y, Z}. Provided that this collection does not change, the cities can be identified by their indices: X => 0, Y => 1, Z => 2.

In certain algorithms, as well as, in certain priority queue implementations in this crate, this convention allows to replace a hashmap with an array. This may be useful in simplifying the algorithms and improving performance when the elements entering the queue are sampled from a closed and known set, as the cities above.

Required Methods§

source

fn index(&self) -> usize

Returns the index of the element.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl HasIndex for u8

source§

fn index(&self) -> usize

source§

impl HasIndex for u16

source§

fn index(&self) -> usize

source§

impl HasIndex for u32

source§

fn index(&self) -> usize

source§

impl HasIndex for u64

source§

fn index(&self) -> usize

source§

impl HasIndex for usize

source§

fn index(&self) -> usize

Implementors§