MONC
Private Member Functions | List of all members
collections_mod::c_free Interface Reference

Frees up all the allocatable, heap, memory associated with a list, stack, queue or map. More...

Private Member Functions

subroutine list_free (specificlist)
 Frees up all the allocatable, heap, memory associated with a specific list. More...
 
subroutine stack_free (specificstack)
 Frees up all the allocatable, heap, memory associated with a specific stack. More...
 
subroutine queue_free (specificqueue)
 Frees up all the allocatable, heap, memory associated with a specific queue. More...
 
subroutine map_free (specificmap)
 Frees up all the allocatable, heap, memory associated with a specific map. More...
 
subroutine hashmap_free (specificmap)
 Frees up all the allocatable, heap, memory associated with a specific hashmap. More...
 
subroutine hashset_free (specificset)
 Frees up all the allocatable, heap, memory associated with a specific set. More...
 

Detailed Description

Frees up all the allocatable, heap, memory associated with a list, stack, queue or map.

This basically acts like a clear operation and once freed the data structure can be reused Note that it does not free the data memory at all as this might be referenced else where in the code This has a time complexity of O(n)

Parameters
collectionThe list, stack, queue or map to delete all members and free all allocated memory of

Definition at line 577 of file collections.F90.

Member Function/Subroutine Documentation

◆ hashmap_free()

subroutine collections_mod::c_free::hashmap_free ( type(hashmap_type), intent(inout)  specificmap)
private

Frees up all the allocatable, heap, memory associated with a specific hashmap.

This basically acts like a clear operation and once freed the data structure can be reused Note that it does not free the value at all as this might be referenced else where in the code Do not call directly from external module, this is called via the appropriate interface

Parameters
specificmapThe hashmap to delete all members and free all allocated memory of

Definition at line 1893 of file collections.F90.

1893  type(hashmap_type), intent(inout) :: specificmap
1894 
1895  type(listnode_type), pointer :: node, previousnode
1896  integer :: i
1897 
1898  if (associated(specificmap%map_ds)) then
1899  do i=1, hash_size
1900  node=>specificmap%map_ds(i)%head
1901  previousnode=>null()
1902 
1903  if (associated(node)) then
1904  do while(1==1)
1905  previousnode=>node
1906  node=>node%next
1907  if (associated(previousnode%data)) then
1908  select type (n=>previousnode%data)
1909  type is (mapnode_type)
1910  if (n%memory_allocation_automatic) then
1911  if (associated(n%value)) deallocate(n%value)
1912  end if
1913  end select
1914  deallocate(previousnode%data) ! Free the mapnode data structure
1915  end if
1916  deallocate(previousnode)
1917  if (.not. associated(node)) exit
1918  end do
1919  end if
1920 
1921  specificmap%map_ds(i)%tail=>null()
1922  specificmap%map_ds(i)%head=>null()
1923  specificmap%map_ds(i)%size=0
1924  end do
1925  specificmap%size=0
1926  deallocate(specificmap%map_ds)
1927  end if

◆ hashset_free()

subroutine collections_mod::c_free::hashset_free ( type(hashset_type), intent(inout)  specificset)
private

Frees up all the allocatable, heap, memory associated with a specific set.

This basically acts like a clear operation and once freed the data structure can be reused Note that it does not free the data memory at all as this might be referenced else where in the code Do not call directly from external module, this is called via the appropriate interface

Parameters
specificsetThe set to delete all members and free all allocated memory of

Definition at line 2115 of file collections.F90.

2115  type(hashset_type), intent(inout) :: specificset
2116 
2117  type(listnode_type), pointer :: node, previousnode
2118  integer :: i
2119 
2120  if (associated(specificset%set_ds)) then
2121  do i=1, hash_size
2122  node=>specificset%set_ds(i)%head
2123  previousnode=>null()
2124 
2125  if (associated(node)) then
2126  do while(1==1)
2127  previousnode=>node
2128  node=>node%next
2129  if (associated(previousnode%data)) then
2130  deallocate(previousnode%data) ! Free the mapnode data structure
2131  end if
2132  deallocate(previousnode)
2133  if (.not. associated(node)) exit
2134  end do
2135  end if
2136 
2137  specificset%set_ds(i)%tail=>null()
2138  specificset%set_ds(i)%head=>null()
2139  specificset%set_ds(i)%size=0
2140  end do
2141  specificset%size=0
2142  deallocate(specificset%set_ds)
2143  end if

◆ list_free()

subroutine collections_mod::c_free::list_free ( type(list_type), intent(inout)  specificlist)
private

Frees up all the allocatable, heap, memory associated with a specific list.

This basically acts like a clear operation and once freed the data structure can be reused Note that it does not free the data memory at all as this might be referenced else where in the code Do not call directly from external module, this is called via the appropriate interface

Parameters
specificlistThe list to delete all members and free all allocated memory of

Definition at line 3146 of file collections.F90.

3146  type(list_type), intent(inout) :: specificlist
3147 
3148  type(listnode_type), pointer :: node, previousnode
3149 
3150  node=>specificlist%head
3151  previousnode=>null()
3152 
3153  if (associated(node)) then
3154  do while(1==1)
3155  previousnode=>node
3156  node=>node%next
3157  if (previousnode%memory_allocation_automatic) then
3158  if (associated(previousnode%data)) deallocate(previousnode%data)
3159  end if
3160  deallocate(previousnode)
3161  if (.not. associated(node)) exit
3162  end do
3163  end if
3164 
3165  specificlist%tail=>null()
3166  specificlist%head=>null()
3167  specificlist%size=0

◆ map_free()

subroutine collections_mod::c_free::map_free ( type(map_type), intent(inout)  specificmap)
private

Frees up all the allocatable, heap, memory associated with a specific map.

This basically acts like a clear operation and once freed the data structure can be reused Note that it does not free the value at all as this might be referenced else where in the code Do not call directly from external module, this is called via the appropriate interface

Parameters
specificmapThe map to delete all members and free all allocated memory of

Definition at line 1222 of file collections.F90.

1222  type(map_type), intent(inout) :: specificmap
1223 
1224  type(listnode_type), pointer :: node, previousnode
1225 
1226  node=>specificmap%map_ds%head
1227  previousnode=>null()
1228 
1229  if (associated(node)) then
1230  do while(1==1)
1231  previousnode=>node
1232  node=>node%next
1233  if (associated(previousnode%data)) then
1234  select type (n=>previousnode%data)
1235  type is (mapnode_type)
1236  if (n%memory_allocation_automatic) then
1237  if (associated(n%value)) deallocate(n%value)
1238  end if
1239  end select
1240  deallocate(previousnode%data) ! Free the mapnode data structure
1241  end if
1242  deallocate(previousnode)
1243  if (.not. associated(node)) exit
1244  end do
1245  end if
1246 
1247  specificmap%map_ds%tail=>null()
1248  specificmap%map_ds%head=>null()
1249  specificmap%map_ds%size=0

◆ queue_free()

subroutine collections_mod::c_free::queue_free ( type(queue_type), intent(inout)  specificqueue)
private

Frees up all the allocatable, heap, memory associated with a specific queue.

This basically acts like a clear operation and once freed the data structure can be reused Note that it does not free the data memory at all as this might be referenced else where in the code Do not call directly from external module, this is called via the appropriate interface

Parameters
specificqueueThe queue to delete all members and free all allocated memory of

Definition at line 2760 of file collections.F90.

2760  type(queue_type), intent(inout) :: specificqueue
2761 
2762  call list_free(specificqueue%queue_ds)

◆ stack_free()

subroutine collections_mod::c_free::stack_free ( type(stack_type), intent(inout)  specificstack)
private

Frees up all the allocatable, heap, memory associated with a specific stack.

This basically acts like a clear operation and once freed the data structure can be reused Note that it does not free the data memory at all as this might be referenced else where in the code Do not call directly from external module, this is called via the appropriate interface

Parameters
specificstackThe stack to delete all members and free all allocated memory of

Definition at line 2464 of file collections.F90.

2464  type(stack_type), intent(inout) :: specificstack
2465 
2466  call list_free(specificstack%stack_ds)

The documentation for this interface was generated from the following file: