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

Removes a specific element from the list or map. More...

Private Member Functions

subroutine list_remove (specificlist, i)
 Removes an element from the list at a specific index. More...
 
subroutine map_remove (specificmap, key)
 Removes a specific key-value pair from the map. More...
 
subroutine hashmap_remove (specificmap, key)
 Removes a specific key-value pair from the hashmap. More...
 
subroutine hashset_remove (specificset, key)
 Removes a string from the hashset. More...
 

Detailed Description

Removes a specific element from the list or map.

This has a time complexity of O(n)

Parameters
collectionThe specific list or map involved
identifierIn the cast of a list the index to remove or for a map the key (of the key-value pair) to remove

Definition at line 419 of file collections.F90.

Member Function/Subroutine Documentation

◆ hashmap_remove()

subroutine collections_mod::c_remove::hashmap_remove ( type(hashmap_type), intent(inout)  specificmap,
character(len=*), intent(in)  key 
)
private

Removes a specific key-value pair from the hashmap.

Do not call directly from external module, this is called via the appropriate interface

Parameters
specificmapThe specific hashmap involved
keyKey of the key-value pair to remove from the map

Definition at line 1668 of file collections.F90.

1668  type(hashmap_type), intent(inout) :: specificmap
1669  character(len=*), intent(in) :: key
1670 
1671  integer :: key_location
1672  class(*), pointer :: raw_map_node
1673 
1674  raw_map_node=>hashmap_getnode(specificmap, key, key_location)
1675 
1676  if (key_location .gt. 0) then
1677  select type (raw_map_node)
1678  type is (mapnode_type)
1679  if (raw_map_node%memory_allocation_automatic) then
1680  if (associated(raw_map_node%value)) deallocate(raw_map_node%value)
1681  end if
1682  deallocate(raw_map_node)
1683  end select
1684  call list_remove(specificmap%map_ds(get_hashkey(key)), key_location)
1685  specificmap%size=specificmap%size-1
1686  end if

◆ hashset_remove()

subroutine collections_mod::c_remove::hashset_remove ( type(hashset_type), intent(inout)  specificset,
character(len=*), intent(in)  key 
)
private

Removes a string from the hashset.

Do not call directly from external module, this is called via the appropriate interface

Parameters
specificsetThe specific ste involved
keyThe string key to remove

Definition at line 1988 of file collections.F90.

1988  type(hashset_type), intent(inout) :: specificset
1989  character(len=*), intent(in) :: key
1990 
1991  integer :: location, hash
1992 
1993  call hashset_getlocation(specificset, key, hash, location)
1994  if (hash .gt. 0 .and. location .gt. 0) then
1995  call list_remove(specificset%set_ds(hash), location)
1996  specificset%size=specificset%size-1
1997  end if

◆ list_remove()

subroutine collections_mod::c_remove::list_remove ( type(list_type), intent(inout)  specificlist,
integer, intent(in)  i 
)
private

Removes an element from the list at a specific index.

Do not call directly from external module, this is called via the appropriate interface

Parameters
specificlistThe specific list involved
iIndex to remove from

Definition at line 2993 of file collections.F90.

2993  type(list_type), intent(inout) :: specificlist
2994  integer, intent(in) :: i
2995 
2996  integer ::j
2997  type(listnode_type), pointer :: node
2998 
2999  j=1
3000  if (i .le. specificlist%size) then
3001  node => specificlist%head
3002  do while(j .lt. i)
3003  if (.not. associated(node)) exit
3004  node => node%next
3005  j=j+1
3006  end do
3007  if (associated(node)) then
3008  if (associated(node%prev)) node%prev%next => node%next
3009  if (associated(node%next)) node%next%prev => node%prev
3010  if (associated(node, target=specificlist%head)) specificlist%head => node%next
3011  if (associated(node, target=specificlist%tail)) specificlist%tail => node%prev
3012  if (node%memory_allocation_automatic) then
3013  if (associated(node%data)) deallocate(node%data)
3014  end if
3015  deallocate(node)
3016  specificlist%size = specificlist%size - 1
3017  end if
3018  end if

◆ map_remove()

subroutine collections_mod::c_remove::map_remove ( type(map_type), intent(inout)  specificmap,
character(len=*), intent(in)  key 
)
private

Removes a specific key-value pair from the map.

Do not call directly from external module, this is called via the appropriate interface

Parameters
specificmapThe specific map involved
keyKey of the key-value pair to remove from the map

Definition at line 1031 of file collections.F90.

1031  type(map_type), intent(inout) :: specificmap
1032  character(len=*), intent(in) :: key
1033 
1034  integer :: key_location
1035  class(*), pointer :: raw_map_node
1036 
1037  raw_map_node=>map_getnode(specificmap, key, key_location)
1038 
1039  if (key_location .gt. 0) then
1040  select type (raw_map_node)
1041  type is (mapnode_type)
1042  if (raw_map_node%memory_allocation_automatic) then
1043  if (associated(raw_map_node%value)) deallocate(raw_map_node%value)
1044  end if
1045  deallocate(raw_map_node)
1046  end select
1047  call list_remove(specificmap%map_ds, key_location)
1048  end if

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