btree_delete_node_i8_dp2d Subroutine

private recursive subroutine btree_delete_node_i8_dp2d(node, pos, keys, values)

Arguments

TypeIntentOptionalAttributesName
type(btree_node_i8_dp2d), POINTER:: node
integer, intent(inout), optional :: pos
integer(kind=keyt), intent(inout), optional DIMENSION(:):: keys
type(btree_data_dp2d), intent(inout), optional DIMENSION(:):: values

Contents


Source Code

      RECURSIVE SUBROUTINE btree_delete_node_i8_dp2d (node, pos, keys, values)
         TYPE(btree_node_i8_dp2d), POINTER :: node
         INTEGER, INTENT(INOUT), OPTIONAL :: pos
         INTEGER(KIND=keyt), DIMENSION(:), INTENT(INOUT), OPTIONAL :: keys
         TYPE(btree_data_dp2d), DIMENSION(:), INTENT(INOUT), OPTIONAL :: values
         !
         INTEGER :: i
         !
         IF (node%filled .GT. 0 .AND. ASSOCIATED(node%subtrees(1)%node)) THEN
            DO i = 1, node%filled + 1
               IF (PRESENT(pos)) THEN
                  CALL btree_delete_node_i8_dp2d (node%subtrees(i)%node, pos, keys, values)
               ELSE
                  CALL btree_delete_node_i8_dp2d (node%subtrees(i)%node)
               END IF
               IF (PRESENT(pos) .AND. i .LE. node%filled) THEN
                  keys(pos) = node%keys(i)
                  values(pos) = node%values(i)
                  pos = pos + 1
               END IF
            END DO
         ELSEIF (PRESENT(pos) .AND. node%filled .GT. 0) THEN
            keys(pos:pos + node%filled - 1) = node%keys(1:node%filled)
            values(pos:pos + node%filled - 1) = node%values(1:node%filled)
            pos = pos + node%filled
         END IF
         CALL btree_free_node_i8_dp2d (node)
      END SUBROUTINE btree_delete_node_i8_dp2d