pub struct OrdinalMap { /* private fields */ }Expand description
A complete bijection from output positions to input positions.
Entry i names the input position copied into output position i. The
constructor validates the complete finite map before it can be applied.
Implementations§
Source§impl OrdinalMap
impl OrdinalMap
Sourcepub fn try_new(output_to_input: Vec<usize>) -> Result<Self, OrdinalMapError>
pub fn try_new(output_to_input: Vec<usize>) -> Result<Self, OrdinalMapError>
Validates a complete bijection over 0..output_to_input.len().
Sourcepub fn identity(cardinality: usize) -> Self
pub fn identity(cardinality: usize) -> Self
Constructs the identity map of the requested cardinality.
Sourcepub fn retrograde(cardinality: usize) -> Self
pub fn retrograde(cardinality: usize) -> Self
Constructs a retrograde map of the requested cardinality.
Sourcepub fn rotation(cardinality: usize, steps: usize) -> Self
pub fn rotation(cardinality: usize, steps: usize) -> Self
Constructs a left rotation by steps, reduced modulo the cardinality.
Sourcepub fn cardinality(&self) -> usize
pub fn cardinality(&self) -> usize
Returns the finite domain cardinality.
Sourcepub fn output_to_input(&self) -> &[usize]
pub fn output_to_input(&self) -> &[usize]
Returns the validated output-to-input ordinal map.
Sourcepub fn is_identity(&self) -> bool
pub fn is_identity(&self) -> bool
Returns whether this map preserves every position.
Sourcepub fn apply<T: Clone>(&self, source: &[T]) -> Result<Vec<T>, OrdinalMapError>
pub fn apply<T: Clone>(&self, source: &[T]) -> Result<Vec<T>, OrdinalMapError>
Applies this map to a slice after checking its cardinality.
Sourcepub fn inverse(&self) -> Result<Self, OrdinalMapError>
pub fn inverse(&self) -> Result<Self, OrdinalMapError>
Returns the exact inverse map.
Sourcepub fn compose(&self, next: &Self) -> Result<Self, OrdinalMapError>
pub fn compose(&self, next: &Self) -> Result<Self, OrdinalMapError>
Composes self followed by next into one canonical map.
Sourcepub fn canonical_form(&self) -> String
pub fn canonical_form(&self) -> String
Returns the deterministic canonical ordinal representation.
Trait Implementations§
Source§impl Clone for OrdinalMap
impl Clone for OrdinalMap
Source§fn clone(&self) -> OrdinalMap
fn clone(&self) -> OrdinalMap
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more