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

Retrieves a map entry at a specific index or null if index > map elements. This is more efficient than calling key at and then value at (or get with the key) as only requires one search for both the key and value. More...

Private Member Functions

logical function map_generic_entry_at (specificmap, i, key, val)
 Retrieves the entry at a specific map index or null if index > map elements. More...
 
logical function hashmap_generic_entry_at (specificmap, i, key, val)
 Retrieves the entry at a specific map index or null if index > map elements. More...
 

Detailed Description

Retrieves a map entry at a specific index or null if index > map elements. This is more efficient than calling key at and then value at (or get with the key) as only requires one search for both the key and value.

This has a time complexity of O(n)

Parameters
collectionThe specific map involved
indexThe index to get value from
keyThe associated key
valueGeneric pointer to corresponding value

Definition at line 519 of file collections.F90.

Member Function/Subroutine Documentation

◆ hashmap_generic_entry_at()

logical function collections_mod::c_generic_entry_at::hashmap_generic_entry_at ( type(hashmap_type), intent(inout)  specificmap,
integer, intent(in)  i,
character(len=*), intent(out)  key,
class(*), intent(out), pointer  val 
)
private

Retrieves the entry at a specific map index or null if index > map elements.

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

Parameters
specificmapThe specific map involved
iIndex to get value from
keyThe associated key
valueGeneric pointer to corresponding value

Definition at line 1640 of file collections.F90.

1641  type(hashmap_type), intent(inout) :: specificmap
1642  integer, intent(in) :: i
1643  character(len=*), intent(out) :: key
1644  class(*), pointer, intent(out) :: val
1645 
1646  class(*), pointer :: raw_map_node
1647 
1648  raw_map_node => hashmap_getnode_atindex(specificmap, i)
1649  if (associated(raw_map_node)) then
1650  select type(raw_map_node)
1651  type is (mapnode_type)
1652  val=>raw_map_node%value
1653  key=raw_map_node%key
1654  end select
1655  hashmap_generic_entry_at=.true.
1656  return
1657  end if
1658  val=>null()
1659  hashmap_generic_entry_at=.false.

◆ map_generic_entry_at()

logical function collections_mod::c_generic_entry_at::map_generic_entry_at ( type(map_type), intent(inout)  specificmap,
integer, intent(in)  i,
character(len=*), intent(out)  key,
class(*), intent(out), pointer  val 
)
private

Retrieves the entry at a specific map index or null if index > map elements.

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

Parameters
specificmapThe specific map involved
iIndex to get value from
keyThe associated key
valueGeneric pointer to corresponding value

Definition at line 999 of file collections.F90.

1000  type(map_type), intent(inout) :: specificmap
1001  integer, intent(in) :: i
1002  character(len=*), intent(out) :: key
1003  class(*), pointer, intent(out) :: val
1004 
1005  class(*), pointer :: raw_map_node
1006  integer :: the_map_size
1007 
1008  the_map_size = map_size(specificmap)
1009  if (i .le. the_map_size) then
1010  raw_map_node=>list_get_generic(specificmap%map_ds, i)
1011  if (associated(raw_map_node)) then
1012  select type(raw_map_node)
1013  type is (mapnode_type)
1014  val=>raw_map_node%value
1015  key=raw_map_node%key
1016  end select
1017  map_generic_entry_at=.true.
1018  return
1019  end if
1020  end if
1021  val=>null()
1022  map_generic_entry_at=.false.

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