fn btree_insert_new_node_and_children(key_values: &mut Vec<(CellRef, CellRef)>, child_nodes: &mut Vec<CellRef>, key_value: (CellRef, CellRef), left: CellRef, right: CellRef) {
    // Search for the first key that's larger than the one we're adding
    for idx in 0..=key_values.len() {
        if idx == key_values.len() {
            // Add at the end (this is the new largest key)
            key_values.push(key_value);
            child_nodes[idx] = left;
            child_nodes.push(right);

            break;
        } else {
            // Insert before the first key that's larger than this one
            match (&*key_values[idx].0).partial_cmp(&*key_value.0) {
                None | Some(Ordering::Less) | Some(Ordering::Equal) => { }
                Some(Ordering::Greater) => {
                    // Insert before this index
                    key_values.insert(idx, key_value);
                    child_nodes[idx] = right;
                    child_nodes.insert(idx, left);

                    break;
                }
            }
        }
    }
}
///
/// Inserts a new key/value and left/right split trees into an existing list (without any further splitting)
///
Inserts a new key/value and left/right split trees into an existing list (without any further splitting)
Inserts a new key / value and left / right split trees into an existing list ( without any further splitting )
fn btree_insert_new_node_and_children(key_values: &mut Vec<(CellRef, CellRef)>, child_nodes: &mut Vec<CellRef>, key_value: (CellRef, CellRef), left: CellRef, right: CellRef) {
    // Search for the first key that's larger than the one we're adding
    for idx in 0..=key_values.len() {
        if idx == key_values.len() {
            // Add at the end (this is the new largest key)
            key_values.push(key_value);
            child_nodes[idx] = left;
            child_nodes.push(right);
            break;
        } else {
            // Insert before the first key that's larger than this one
            match (&*key_values[idx].0).partial_cmp(&*key_value.0) {
                None | Some(Ordering::Less) | Some(Ordering::Equal) => { }
                Some(Ordering::Greater) => {
                    // Insert before this index
                    key_values.insert(idx, key_value);
                    child_nodes[idx] = right;
                    child_nodes.insert(idx, left);
                    break;
                }
            }
        }
    }
}
fn btree_insert_new_node_and_children ( key_values : & mut Vec < ( CellRef , CellRef ) > , child_nodes : & mut Vec < CellRef > , key_value : ( CellRef , CellRef ) , left : CellRef , right : CellRef ) { // Search for the first key that's larger than the one we're adding for idx in 0 ..= key_values . len ( ) { if idx == key_values . len ( ) { // Add at the end (this is the new largest key) key_values . push ( key_value ) ; child_nodes [ idx ] = left ; child_nodes . push ( right ) ; break ; } else { // Insert before the first key that's larger than this one match ( & * key_values [ idx ] . 0 ) . partial_cmp ( & * key_value . 0 ) { None | Some ( Ordering :: Less ) | Some ( Ordering :: Equal ) => { } Some ( Ordering :: Greater ) => { // Insert before this index key_values . insert ( idx , key_value ) ; child_nodes [ idx ] = right ; child_nodes . insert ( idx , left ) ; break ; } } } } }
Inserts a new key/value and left/right split trees into an existing list (without any further splitting)
Inserts a new key / value and left / right split trees into an existing list ( without any further splitting )
key_values
&mut Vec<(CellRef, CellRef)>
child_nodes
&mut Vec<CellRef>
key_value
(CellRef, CellRef)
left
CellRef
right
CellRef
key_values
&mut Vec<(CellRef, CellRef)>
child_nodes
&mut Vec<CellRef>
key_value
(CellRef, CellRef)
left
CellRef
right
CellRef