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 2v.card([0])
is 4v.card([1])
is 6
Required Methods§
Sourcefn is_rectangular(&self) -> bool
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 thatcard([])
is n andcard([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 thatcard([])
is n,card([i])
is m for all i, andcard([i, j])
os p for all (i,j). - Empty vector of any dimension.
Sourcefn cardinality_of(&self, idx: impl Into<D::CardIdx>) -> usize
fn cardinality_of(&self, idx: impl Into<D::CardIdx>) -> usize
Returns the cardinality of the child of the vector at the given idx
.
Sourcefn child_card(&self, left_most_idx: D::ChildIdx) -> impl Card<D::PrevDim>
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
.
Sourcefn child_fun<T, F>(
&self,
left_most_idx: D::ChildIdx,
fun: F,
) -> impl Fn(<D::PrevDim as Dim>::Idx) -> T
fn child_fun<T, F>( &self, left_most_idx: D::ChildIdx, fun: F, ) -> impl Fn(<D::PrevDim as Dim>::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])
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.