Doubly-linked list/Definition: Difference between revisions

Content added Content deleted
(added Unicon example)
Line 841:
 
=={{header|Fortran}}==
Tested with g95 and gfortran v. 4.6.
<lang fortran>
module dlist
Line 862:
contains
! Create a new doubly-linked list
elemental type(dll) function new_dll()
new_dll = dll(null(),null(),0)
return
end function new_dll
 
! Append an element to the end of the list
elemental subroutine append(dl2, value)
type(dll), intent(inout) :: dl2
integer, intent(in) :: value
 
type(node) :: element
type(node), pointer :: np
 
Line 891 ⟶ 890:
 
! Prepend an element to the beginning of the list
elemental subroutine prepend(dl2, value)
type(dll), intent(inout) :: dl2
integer, intent(in) :: value
 
type(node) :: element
type(node), pointer :: np
 
Line 912 ⟶ 910:
 
! Insert immediately before the given index
elemental subroutine insert(dl2, index, value)
type(dll), intent(inout) :: dl2
integer, intent(in) :: index
Line 1,022 ⟶ 1,020:
end subroutine tidy
 
elemental subroutine init(dl2, value)
type(dll), intent(inout) :: dl2
integer, intent(in) :: value