orx_v/dim/index_leq/
leq_d4.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use super::LeqIdx;
use crate::{IdxLeqD4, NVecCore, NVecCoreSealed, D4};

impl LeqIdx<D4> for IdxLeqD4 {
    fn in_leq_bounds<T>(self, vec: &impl NVecCore<D4, T>) -> bool {
        match self {
            Self::IdxD0(_) => true,
            Self::IdxD1([i]) => i < vec.core_num_children(),
            Self::IdxD2([i, j]) => {
                i < vec.core_num_children() && j < vec.core_child(i).core_num_children()
            }
            Self::IdxD3([i, j, k]) => {
                i < vec.core_num_children()
                    && j < vec.core_child(i).core_num_children()
                    && k < vec.core_child(i).core_child(j).core_num_children()
            }
            Self::IdxD4([i, j, k, l]) => {
                i < vec.core_num_children()
                    && j < vec.core_child(i).core_num_children()
                    && k < vec.core_child(i).core_child(j).core_num_children()
                    && l < vec
                        .core_child(i)
                        .core_child(j)
                        .core_child(k)
                        .core_num_children()
            }
        }
    }
}