btree_right_insertion_i8_dp2d Subroutine

private subroutine btree_right_insertion_i8_dp2d(tree, node, new_node, key, value, before, split_pos, subtree)

Arguments

Type IntentOptional Attributes Name
type(btree_i8_dp2d), intent(in) :: tree
type(btree_node_i8_dp2d), intent(inout) :: node
type(btree_node_i8_dp2d), intent(inout) :: new_node
integer(kind=keyt), intent(in) :: key
type(btree_data_dp2d), intent(in) :: value
integer, intent(in) :: before
integer, intent(in) :: split_pos
type(btree_node_i8_dp2d), optional, POINTER :: subtree

Source Code

      SUBROUTINE btree_right_insertion_i8_dp2d (tree, node, new_node, key, value, before, split_pos, subtree)
         TYPE(btree_i8_dp2d), INTENT(IN) :: tree
         TYPE(btree_node_i8_dp2d), INTENT(INOUT) :: node, new_node
         INTEGER(KIND=keyt), INTENT(IN) :: key
         TYPE(btree_data_dp2d), INTENT(IN) :: value
         INTEGER, INTENT(IN) :: before, split_pos
         TYPE(btree_node_i8_dp2d), POINTER, OPTIONAL :: subtree
         !
         new_node%filled = (tree%b%max_fill + 1) - split_pos
         new_node%keys(1:before - split_pos - 1) = &
            node%keys(split_pos + 1:before - 1)
         new_node%keys(before - split_pos) = key
         new_node%keys(before - split_pos + 1:new_node%filled) = &
            node%keys(before:tree%b%max_fill)
         new_node%values(1:before - split_pos - 1) = &
            node%values(split_pos + 1:before - 1)
         new_node%values(before - split_pos) = value
         new_node%values(before - split_pos + 1:new_node%filled) = &
            node%values(before:tree%b%max_fill)
         IF (PRESENT(subtree)) THEN
            new_node%subtrees(1:before - split_pos) = &
               node%subtrees(split_pos + 1:before)
            new_node%subtrees(before - split_pos + 1)%node => subtree
            new_node%subtrees(before - split_pos + 2:new_node%filled + 1) = &
               node%subtrees(before + 1:tree%b%max_fill + 1)
         END IF
      END SUBROUTINE btree_right_insertion_i8_dp2d