Inserts a generic element into the list or places at the end if the index > list size.
More...
|
subroutine | list_insert_generic (specificlist, data, i, memory_allocation_automatic) |
| Inserts an element into the list or places at the end if the index > list size. More...
|
|
Inserts a generic element into the list or places at the end if the index > list size.
This has a time complexity of O(n)
- Parameters
-
collection | The specific list involved |
data | Pointer to the generic data to insert |
index | The list index to insert to |
memory_allocation_automatic | Whether the collections API should manage the freeing of memory |
Definition at line 251 of file collections.F90.
◆ list_insert_generic()
subroutine collections_mod::c_insert_generic::list_insert_generic |
( |
type(list_type), intent(inout) |
specificlist, |
|
|
class(*), intent(in), pointer |
data, |
|
|
integer, intent(in) |
i, |
|
|
logical, intent(in) |
memory_allocation_automatic |
|
) |
| |
|
private |
Inserts an element into the list or places at the end if the index > list size.
Do not call directly from external module, this is called via the appropriate interface
- Parameters
-
specificlist | The specific list involved |
data | Pointer to the generic data to insert |
i | The list index to insert to |
Definition at line 2850 of file collections.F90.
2850 type(list_type),
intent(inout) :: specificlist
2851 integer,
intent(in) :: i
2852 class(*),
pointer,
intent(in) :: data
2853 logical,
intent(in) :: memory_allocation_automatic
2856 type(listnode_type),
pointer :: newnode, node
2859 newnode%data =>
data 2862 node => specificlist%head
2863 if (
associated(node))
then 2865 if (.not.
associated(node%next))
exit 2871 newnode%next => node
2872 newnode%prev => node%prev
2873 newnode%memory_allocation_automatic=memory_allocation_automatic
2874 if (
associated(node%prev)) node%prev%next=>newnode
2875 node%prev => newnode
2876 if (
associated(node,
target=specificlist%head)) specificlist%head=>newnode
2879 newnode%prev=>specificlist%tail
2880 if (
associated(specificlist%tail))
then 2881 specificlist%tail%next => newnode
2883 specificlist%tail => newnode
2885 if (
associated(specificlist%head) .eqv. .false.)
then 2886 specificlist%head=>newnode
2891 specificlist%head => newnode
2892 specificlist%tail => newnode
2894 specificlist%size=specificlist%size+1
The documentation for this interface was generated from the following file:
- /nfs/a277/earlcd/dev/monc/svn-git/monc/model_core/src/utils/collections.F90