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

Adds a generic element to the end of the list. More...

Private Member Functions

subroutine list_add_generic (specificlist, data, memory_allocation_automatic)
 Adds an element to the end of the list. More...
 

Detailed Description

Adds a generic element to the end of the list.

This has a time complexity of O(1)

Parameters
collectionThe specific list involved
dataPointer to the raw generic data to add
memory_allocation_automaticWhether the collections API should manage the freeing of memory

Definition at line 204 of file collections.F90.

Member Function/Subroutine Documentation

◆ list_add_generic()

subroutine collections_mod::c_add_generic::list_add_generic ( type(list_type), intent(inout)  specificlist,
class(*), intent(in), pointer  data,
logical, intent(in)  memory_allocation_automatic 
)
private

Adds an element to the end of the list.

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

Parameters
specificlistThe specific list involved
dataPointer to the generic data to add
memory_allocation_automaticWhether the collections API should manage the freeing of memory

Definition at line 2963 of file collections.F90.

2964  type(list_type), intent(inout) :: specificlist
2965  class(*), pointer, intent(in) :: data
2966  logical, intent(in) :: memory_allocation_automatic
2967 
2968  type(listnode_type), pointer :: newnode
2969 
2970  allocate(newnode)
2971  newnode%data => data
2972 
2973  newnode%prev=>specificlist%tail
2974  newnode%memory_allocation_automatic=memory_allocation_automatic
2975  if (associated(specificlist%tail)) then
2976  specificlist%tail%next => newnode
2977  end if
2978  specificlist%tail => newnode
2979 
2980  if (associated(specificlist%head) .eqv. .false.) then
2981  specificlist%head=>newnode
2982  end if
2983 
2984  specificlist%size=specificlist%size+1

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