45 INTEGER(INTG),
INTENT(IN) :: data
46 INTEGER(INTG),
INTENT(OUT) :: ERR
51 enters(
"LinkedList_Add_Data",err,error,*999)
53 if (
associated(list%root))
then 56 allocate(current%next)
57 current%next%data =
data 58 list%last => current%next
62 list%last => list%root
65 exits(
"LinkedList_Add_Data")
67 999 errorsexits(
"LinkedList_Add_Data",err,error)
79 INTEGER(INTG),
INTENT(OUT) :: ERR
86 current => addlist%root
89 if (
associated(current%next))
then 90 current => current%next
96 exits(
"LinkedList_Add_List")
98 999 errorsexits(
"LinkedList_Add_List",err,error)
108 integer(intg),
intent(out) :: data
109 INTEGER(INTG),
INTENT(OUT) :: ERR
114 if (
associated(list%root))
then 115 data = list%root%data
116 next => list%root%next
117 deallocate(list%root)
119 if (
associated(list%root))
then 120 if (.not.
associated(list%root%next)) list%last => list%root
125 write(*,*)
">>> warning: linked list is empty and cannot remove first item" 135 integer(intg),
intent(out) :: data
136 INTEGER(INTG),
INTENT(OUT) :: ERR
141 if (.not.
associated(list%root))
then 142 write(*,*)
">>> warning: linked list is empty and cannot remove last item" 148 if (
associated(current%next))
then 149 if (
associated(current%next%next))
then 150 current => current%next
153 data = current%next%data
154 deallocate(current%next)
155 current%next => null()
162 deallocate(list%root)
177 INTEGER(INTG),
INTENT(OUT) :: ERR
182 if (.not.
associated(list%root))
return 186 if (
associated(current%next))
then 206 logical :: LinkedList_is_Empty
208 linkedlist_is_empty = .true.
209 if (
associated(list%root)) linkedlist_is_empty = .false.
218 integer(INTG),
allocatable,
intent(out) :: array(:)
219 INTEGER(INTG),
INTENT(OUT) :: ERR
235 if (
associated(current%next))
then 237 current => current%next
244 if (
allocated(array))
deallocate(array)
245 allocate(array(n),stat=err)
249 array(i)=current%data
250 current => current%next
subroutine, public enters(NAME, ERR, ERROR,)
Records the entry into the named procedure and initialises the error code.
subroutine, public linkedlist_destroy(list, ERR, ERROR,)
will delete and deallocate all items
subroutine, public linkedlist_remove_last(list, data, ERR, ERROR,)
removes the first item from list and returns its value in data
subroutine, public linkedlist_to_array(list, array, ERR, ERROR,)
copies out the data to an allocatable array
This module provides an iso_varying_string module, conformant to the API specified in ISO/IEC 1539-2:...
Only for integer data type for now.
This module contains all program wide constants.
subroutine, public exits(NAME)
Records the exit out of the named procedure.
subroutine linkedlist_add_list(list, addlist, ERR, ERROR,)
adds all data from one list to another
This module contains all the low-level base routines e.g., all debug, control, and low-level communic...
subroutine, public linkedlist_remove_first(list, data, ERR, ERROR,)
removes the first item from list and returns its value in data
subroutine linkedlist_add_data(list, data, ERR, ERROR,)
initialises or adds a piece of data to list
logical function, public linkedlist_is_empty(list)
returns true if the list is empty
This module contains all kind definitions.