btree_right_insertion_i8_cp2d Subroutine

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

Arguments

TypeIntentOptionalAttributesName
type(btree_i8_cp2d), intent(in) :: tree
type(btree_node_i8_cp2d), intent(inout) :: node
type(btree_node_i8_cp2d), intent(inout) :: new_node
integer(kind=keyt), intent(in) :: key
type(btree_data_cp2d), intent(in) :: value
integer, intent(in) :: before
integer, intent(in) :: split_pos
type(btree_node_i8_cp2d), optional POINTER:: subtree

Contents


Source Code

      SUBROUTINE btree_right_insertion_i8_cp2d (tree, node, new_node, key, value, before, split_pos, subtree)
         TYPE(btree_i8_cp2d), INTENT(IN) :: tree
         TYPE(btree_node_i8_cp2d), INTENT(INOUT) :: node, new_node
         INTEGER(KIND=keyt), INTENT(IN) :: key
         TYPE(btree_data_cp2d), INTENT(IN) :: value
         INTEGER, INTENT(IN) :: before, split_pos
         TYPE(btree_node_i8_cp2d), 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_cp2d