Trait lattice_graph::lattice_abstract::shapes::Axis
source · [−]pub trait Axis: Copy + PartialEq {
type Direction: AxisDirection;
const COUNT: usize;
const DIRECTED: bool;
const UNDIRECTED_COUNT: usize;
fn to_index(&self) -> usize;
fn from_index(index: usize) -> Option<Self>
where
Self: Sized;
fn foward(self) -> Self::Direction;
fn backward(self) -> Self::Direction;
fn from_direction(dir: Self::Direction) -> Self;
unsafe fn from_index_unchecked(index: usize) -> Self { ... }
fn is_forward_direction(dir: &Self::Direction) -> bool { ... }
}
Expand description
Axis of the graph. It holds what direction of edge which node has.
Associated Types
type Direction: AxisDirection
type Direction: AxisDirection
For tricks to optimize for undirected graph, and not to regress performance of directed graph.
If the axis is DIRECTED
, should set Self
.
Associated Constants
const UNDIRECTED_COUNT: usize
const UNDIRECTED_COUNT: usize
Number of direction. If this axis is not directed, it is COUNT * 2
, otherwise COUNT
.
Required methods
fn from_index(index: usize) -> Option<Self> where
Self: Sized,
fn from_index(index: usize) -> Option<Self> where
Self: Sized,
Convert form index.
fn from_direction(dir: Self::Direction) -> Self
fn from_direction(dir: Self::Direction) -> Self
Convert from direction.
Provided methods
unsafe fn from_index_unchecked(index: usize) -> Self
unsafe fn from_index_unchecked(index: usize) -> Self
Convert form index.
fn is_forward_direction(dir: &Self::Direction) -> bool
fn is_forward_direction(dir: &Self::Direction) -> bool
Check the direction is forward for this axis.
Returns true if the direction is DIRECTED
is true
, or the index of the axis and direction matches.