libsim Versione 7.2.6
list_link.F03
1!> \brief class to manage links for lists in fortran 2003.
2!!
3!! Linked data structure is a data structure which
4!! consists of a set of data records (nodes) linked together and organized by references.
5!! This module is used by other lists modules.
6!!\ingroup base
7module list_link
8 private
9 public :: link
10!> Base type to manage links for lists
11 type link
12 private
13 class(*), pointer :: value => null() !< value stored in link
14 type(link), pointer :: next => null()!< next link in list
15 type(link), pointer :: prev => null()!< next link in list
16 contains
17 procedure :: getValue !< return value pointer
18 procedure :: nextLink !< return next pointer
19 procedure :: prevLink !< return next pointer
20 procedure :: setNextLink !< set next pointer
21 procedure :: setPrevLink !< set next pointer
22 end type link
23
24!> User-defined constructors => list_link::constructor
25 interface link
26 procedure constructor !< construct/initialize a link
27 end interface
28
29contains
30
31function nextlink(this)
32class(link) :: this
33class(link), pointer :: nextLink
34nextlink => this%next
35end function nextlink
36
37function prevlink(this)
38class(link) :: this
39class(link), pointer :: prevLink
40prevlink => this%prev
41end function prevlink
42
43subroutine setnextlink(this,next)
44class(link) :: this
45type(link), pointer :: next
46this%next => next
47end subroutine setnextlink
49subroutine setprevlink(this,prev)
50class(link) :: this
51type(link), pointer :: prev
52this%prev => prev
53end subroutine setprevlink
55function getvalue(this)
56class(link),intent(in) :: this
57class(*), pointer :: getvalue
58getvalue => this%value
59end function getvalue
61!> Constructor
62function constructor(value)
63type(link),pointer :: constructor
64class(*),intent(in) :: value !< value for list
65allocate(constructor)
66constructor%prev => null()
67constructor%next => null()
68allocate(constructor%value, source=value)
69end function constructor
70
71end module list_link

Generated with Doxygen.