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

Puts a generic key-value pair into the map. More...

Private Member Functions

subroutine map_put_generic (specificmap, key, data, memory_allocation_automatic)
 Puts a specific key-value pair into the map. More...
 
subroutine hashmap_put_generic (specificmap, key, data, memory_allocation_automatic)
 Puts a specific key-value pair into the hashmap. More...
 

Detailed Description

Puts a generic key-value pair into the map.

If the key is not already held in the map then the key-value pair will be added, otherwise the existing key-value pair will be modified to hold this updated value (keys must be unique) This has a time complexity of O(n) due to key look up

Parameters
collectionThe specific map involved
keyThe key to place in the map
valuePointer to the generic data value to place in the map
memory_allocation_automaticWhether the collections API should manage the freeing of memory

Definition at line 305 of file collections.F90.

Member Function/Subroutine Documentation

◆ hashmap_put_generic()

subroutine collections_mod::c_put_generic::hashmap_put_generic ( type(hashmap_type), intent(inout)  specificmap,
character(len=*), intent(in)  key,
class(*), intent(in), pointer  data,
logical, intent(in)  memory_allocation_automatic 
)
private

Puts a specific key-value pair into the hashmap.

If the key is not already held in the hashmap then the key-value pair will be added, otherwise the existing key-value pair will be modified to hold this updated value (keys must be unique). This uses a hashing function for performance Do not call directly from external module, this is called via the appropriate interface

Parameters
specificmapThe specific map involved
keyThe key to place in the map
dataPointer to the generic data value to place in the map
memory_allocation_automaticWhether the collections API should manage the freeing of memory

Definition at line 1364 of file collections.F90.

1365  type(hashmap_type), intent(inout) :: specificmap
1366  class(*), pointer, intent(in) :: data
1367  character(len=*), intent(in) :: key
1368  logical, intent(in) :: memory_allocation_automatic
1369 
1370  class(*), pointer :: raw_map_node, generic_map_node
1371  type(mapnode_type), pointer :: newmapnode
1372 
1373  if (.not. associated(specificmap%map_ds)) allocate(specificmap%map_ds(hash_size))
1374 
1375  ! Test to see if key already exists in the map
1376  raw_map_node=>hashmap_getnode(specificmap, key)
1377 
1378  if (associated(raw_map_node)) then
1379  select type(raw_map_node)
1380  type is (mapnode_type)
1381  raw_map_node%value=>data
1382  end select
1383  else
1384  allocate(newmapnode)
1385  newmapnode%value=>data
1386  newmapnode%key=key
1387  newmapnode%memory_allocation_automatic=memory_allocation_automatic
1388  ! Clone and deallocate the newmapnode - this keeps GNU happy with passing the correct pointer and Cray
1389  ! doesn't link the generic pointer just pointing to the data structure hence we clone it
1390  allocate(generic_map_node, source=newmapnode)
1391  deallocate(newmapnode)
1392  call list_add_generic(specificmap%map_ds(get_hashkey(key)), generic_map_node, .false.)
1393  specificmap%size=specificmap%size+1
1394  end if

◆ map_put_generic()

subroutine collections_mod::c_put_generic::map_put_generic ( type(map_type), intent(inout)  specificmap,
character(len=*), intent(in)  key,
class(*), intent(in), pointer  data,
logical, intent(in)  memory_allocation_automatic 
)
private

Puts a specific key-value pair into the map.

If the key is not already held in the map then the key-value pair will be added, otherwise the existing key-value pair will be modified to hold this updated value (keys must be unique) Do not call directly from external module, this is called via the appropriate interface

Parameters
specificmapThe specific map involved
keyThe key to place in the map
dataPointer to the generic data value to place in the map
memory_allocation_automaticWhether the collections API should manage the freeing of memory

Definition at line 725 of file collections.F90.

726  type(map_type), intent(inout) :: specificmap
727  class(*), pointer, intent(in) :: data
728  character(len=*), intent(in) :: key
729  logical, intent(in) :: memory_allocation_automatic
730 
731  class(*), pointer :: raw_map_node, generic_map_node
732  type(mapnode_type), pointer :: newmapnode
733 
734  ! Test to see if key already exists in the map
735  raw_map_node=>map_getnode(specificmap, key)
736 
737  if (associated(raw_map_node)) then
738  select type(raw_map_node)
739  type is (mapnode_type)
740  raw_map_node%value => data
741  end select
742  else
743  allocate(newmapnode)
744  newmapnode%value => data
745  newmapnode%key = key
746  newmapnode%memory_allocation_automatic=memory_allocation_automatic
747  ! Clone and deallocate the newmapnode - this keeps GNU happy with passing the correct pointer and Cray
748  ! doesn't link the generic pointer just pointing to the data structure hence we clone it
749  allocate(generic_map_node, source=newmapnode)
750  deallocate(newmapnode)
751  call list_add_generic(specificmap%map_ds, generic_map_node, .false.)
752  end if

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