orx_v

Trait Card

Source
pub trait Card<D: Dim> {
    // Required methods
    fn is_rectangular(&self) -> bool;
    fn cardinality_of(&self, idx: impl Into<D::CardIdx>) -> usize;
    fn child_card(&self, left_most_idx: D::ChildIdx) -> impl Card<D::PrevDim>;
    fn child_fun<T, F>(
        &self,
        left_most_idx: D::ChildIdx,
        fun: F,
    ) -> impl Fn(<D::PrevDim as Dim>::Idx) -> T
       where F: Fn(D::Idx) -> T;
    fn vec_all<'a, T, N>(&'a self, vec: &'a N) -> impl Iterator<Item = T>
       where N: NVec<D, T> + 'a;
    fn vec_enumerate_all<'a, T, N>(
        &'a self,
        vec: &'a N,
    ) -> impl Iterator<Item = (D::Idx, T)>
       where N: NVec<D, T> + 'a;
}
Expand description

Cardinality of a vector.

Note that cardinality of a vector of dimension D is capable of providing the number of elements of all lower dimension children of the vector.

Consider, for instance a jagged vector of dimension D2, say v2, including two vectors of lengths 4 and 6. Then its cardinality is capable of creating all relevant cardinality information:

  • v.card([]) is 2
  • v.card([0]) is 4
  • v.card([1]) is 6

Required Methods§

Source

fn is_rectangular(&self) -> bool

Returns true if the cardinality is bounded and rectangular; i.e,

  • children of a particular dimension have the same number of children.

The following are example multi-dimensional vectors with rectangular cardinality:

  • All D1 vectors.
  • D2 vector representing n-by-m matrices such that card([]) is n and card([i]) is m for all i in 0..n.
  • Similarly, higher dimensional vectors representing higher dimensional matrices such as a D3 vector representing n-by-m-by-p matrix such that card([]) is n, card([i]) is m for all i, and card([i, j]) os p for all (i,j).
  • Empty vector of any dimension.
Source

fn cardinality_of(&self, idx: impl Into<D::CardIdx>) -> usize

Returns the cardinality of the child of the vector at the given idx.

Source

fn child_card(&self, left_most_idx: D::ChildIdx) -> impl Card<D::PrevDim>

Returns the cardinality of the child of this vector at the given left_most_idx.

Source

fn child_fun<T, F>( &self, left_most_idx: D::ChildIdx, fun: F, ) -> impl Fn(<D::PrevDim as Dim>::Idx) -> T
where F: Fn(D::Idx) -> T,

Creates a function, say new_fun, which applies the first of the indices to left_most_index such that:

new_fun([i, j, k]) returns fun([left_most_idx, i, j, k])

Source

fn vec_all<'a, T, N>(&'a self, vec: &'a N) -> impl Iterator<Item = T>
where N: NVec<D, T> + 'a,

Returns an iterator over all elements of the vec provided that this is its cardinality.

Source

fn vec_enumerate_all<'a, T, N>( &'a self, vec: &'a N, ) -> impl Iterator<Item = (D::Idx, T)>
where N: NVec<D, T> + 'a,

Returns an iterator over all elements of the vec together with their corresponding indices provided that this is its cardinality.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<D: Dim, C: Card<D>> Card<D> for &C

Source§

fn is_rectangular(&self) -> bool

Source§

fn cardinality_of(&self, idx: impl Into<<D as Dim>::CardIdx>) -> usize

Source§

fn child_card( &self, left_most_idx: D::ChildIdx, ) -> impl Card<<D as Dim>::PrevDim>

Source§

fn child_fun<T, F>( &self, left_most_idx: D::ChildIdx, fun: F, ) -> impl Fn(<<D as Dim>::PrevDim as Dim>::Idx) -> T
where F: Fn(<D as Dim>::Idx) -> T,

Source§

fn vec_all<'a, T, N>(&'a self, vec: &'a N) -> impl Iterator<Item = T>
where N: NVec<D, T> + 'a,

Source§

fn vec_enumerate_all<'a, T, N>( &'a self, vec: &'a N, ) -> impl Iterator<Item = (<D as Dim>::Idx, T)>
where N: NVec<D, T> + 'a,

Implementors§