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§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".