27 type(LINKED_LIST),
pointer :: next
28 type(LIST_DATA) :: data
81 subroutine list_create( list, data )
82 type(LINKED_LIST),
pointer :: list
83 type(LIST_DATA),
intent(in) :: data
88 end subroutine list_create
98 subroutine list_destroy( list )
99 type(LINKED_LIST),
pointer :: list
101 type(LINKED_LIST),
pointer :: current
102 type(LINKED_LIST),
pointer :: next
105 do while (
associated(current) )
107 call finalize_table( current%data%value )
108 deallocate( current )
111 end subroutine list_destroy
118 integer function list_count( list )
119 type(LINKED_LIST),
pointer :: list
121 type(LINKED_LIST),
pointer :: current
124 if (
associated(list) )
then
127 do while (
associated(current%next) )
128 current => current%next
129 list_count = list_count + 1
134 end function list_count
142 function list_next( elem )
result(next)
143 type(LINKED_LIST),
pointer :: elem
144 type(LINKED_LIST),
pointer :: next
148 end function list_next
157 subroutine list_insert( elem, data )
158 type(LINKED_LIST),
pointer :: elem
159 type(LIST_DATA),
intent(in) :: data
161 type(LINKED_LIST),
pointer :: next
165 next%next => elem%next
168 end subroutine list_insert
176 subroutine list_insert_head( list, data )
177 type(LINKED_LIST),
pointer :: list
178 type(LIST_DATA),
intent(in) :: data
180 type(LINKED_LIST),
pointer :: elem
187 end subroutine list_insert_head
196 subroutine list_delete_element( list, elem )
197 type(LINKED_LIST),
pointer :: list
198 type(LINKED_LIST),
pointer :: elem
200 type(LINKED_LIST),
pointer :: current
201 type(LINKED_LIST),
pointer :: prev
203 if (
associated(list,elem) )
then
209 do while (
associated(current) )
210 if (
associated(current,elem) )
then
211 prev%next => current%next
212 deallocate( current )
216 current => current%next
224 end subroutine list_delete_element
231 function list_get_data( elem )
result(data)
232 type(LINKED_LIST),
pointer :: elem
234 type(LIST_DATA) :: data
237 end function list_get_data
245 subroutine list_put_data( elem, data )
246 type(LINKED_LIST),
pointer :: elem
247 type(LIST_DATA),
intent(in) :: data
250 end subroutine list_put_data