pub fn find_siblings(
    sorted: &[DefaultKey],
) -> Vec<(DefaultKey, Option<DefaultKey>, Option<DefaultKey>)> {
    let mut res = Vec::with_capacity(sorted.len());
    let length = sorted.len();

    for (i, key) in sorted.iter().enumerate() {
        let mut with_siblings = (*key, None, None);

        if i > 0 {
            // lighter / later
            with_siblings.1 = Some(sorted[i - 1]);
        }

        if i < length - 1 {
            // heavier/earlier
            with_siblings.2 = Some(sorted[i + 1]);
        }
        res.push(with_siblings);
    }

    res
}
/// Find the lighter/heavier and earlier/later pages for all pages having a date/weight
Find the lighter/heavier and earlier/later pages for all pages having a date/weight
Find the lighter / heavier and earlier / later pages for all pages having a date / weight
pub fn find_siblings(
    sorted: &[DefaultKey],
) -> Vec<(DefaultKey, Option<DefaultKey>, Option<DefaultKey>)> {
    let mut res = Vec::with_capacity(sorted.len());
    let length = sorted.len();
    for (i, key) in sorted.iter().enumerate() {
        let mut with_siblings = (*key, None, None);
        if i > 0 {
            // lighter / later
            with_siblings.1 = Some(sorted[i - 1]);
        }
        if i < length - 1 {
            // heavier/earlier
            with_siblings.2 = Some(sorted[i + 1]);
        }
        res.push(with_siblings);
    }
    res
}
pub fn find_siblings ( sorted : & [ DefaultKey ] , ) -> Vec < ( DefaultKey , Option < DefaultKey > , Option < DefaultKey > ) > { let mut res = Vec :: with_capacity ( sorted . len ( ) ) ; let length = sorted . len ( ) ; for ( i , key ) in sorted . iter ( ) . enumerate ( ) { let mut with_siblings = ( * key , None , None ) ; if i > 0 { // lighter / later with_siblings . 1 = Some ( sorted [ i - 1 ] ) ; } if i < length - 1 { // heavier/earlier with_siblings . 2 = Some ( sorted [ i + 1 ] ) ; } res . push ( with_siblings ) ; } res }
Find the lighter/heavier and earlier/later pages for all pages having a date/weight
Find the lighter / heavier and earlier / later pages for all pages having a date / weight
sorted
&[DefaultKey]
sorted
&[DefaultKey]