add_clone Subroutine

private subroutine add_clone(me, key, value)

Add an item to the end of the list by cloning it. That is, using a sourced allocation: allocate(newitem, source=value). A clone is made of the original value, which is not affected. The list contains only the clone, which will be deallocated (and finalized if a finalizer is present) when removed from the list.

This is different from the add_pointer routine, which takes a pointer input.

This one would normally be used for basic variables and types that do not contain pointers to other variables (and are not pointed to by other variables)

Type Bound

list

Arguments

Type IntentOptional Attributes Name
class(list), intent(inout) :: me
class(*), intent(in) :: key
class(*), intent(in) :: value

Calls

proc~~add_clone~~CallsGraph proc~add_clone list%add_clone proc~add_pointer list%add_pointer proc~add_clone->proc~add_pointer proc~get_node list%get_node proc~add_pointer->proc~get_node proc~remove_by_pointer list%remove_by_pointer proc~add_pointer->proc~remove_by_pointer proc~keys_equal list%keys_equal proc~get_node->proc~keys_equal proc~destroy_node_data node%destroy_node_data proc~remove_by_pointer->proc~destroy_node_data proc~uppercase uppercase proc~keys_equal->proc~uppercase

Source Code

    subroutine add_clone(me,key,value)

    implicit none

    class(list),intent(inout) :: me
    class(*),intent(in)       :: key
    class(*),intent(in)       :: value

    class(*),pointer :: p_value

    allocate(p_value, source=value) !make a copy
    call me%add_pointer(key,p_value,destroy_on_delete=.true.)
    nullify(p_value)

    end subroutine add_clone