libsim Versione 7.2.6
list_mix.F03
1!> \brief class to use 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!!
6!! A doubly-linked list is a linked data structure that consists of a set
7!! of sequentially linked records called nodes. Each node contains two
8!! fields, called links, that are references to the previous and to the
9!! next node in the sequence of nodes. The beginning and ending nodes'
10!! previous and next links, respectively, point to some kind of
11!! terminator.
12!!
13!! The program example is the better starting point:
14!!\include example_list.F03
15!!\ingroup base
16!!
17module list_mix
19use kinds
20private
21!> Non type specific implementation of doubly-linked list
22!!
23!! extend list_abstract::list
24type,public,extends(list) :: mixlist
25#ifdef DOXYGEN
26 integer::none ! doxigen workaround: if missed do not show procedure
27#endif
28 contains
29 procedure :: current => currentmix !< get integer pointed by iterator
30 procedure :: display => displaymix !< print the integer list
31end type mixlist
32
33contains
34
35!> Print the list
36subroutine displaymix(this)
37class(mixList),intent(inout) :: this
38class(*), pointer :: curr
39logical :: found
40
41call this%rewind()
42do while(this%element())
43 curr => this%Currentpoli()
44 found=.false.
45 select type(curr)
46 type is (integer)
47 print *,curr
48 found=.true.
49 type is (real)
50 print *,curr
51 found=.true.
52 type is (doubleprecision)
53 print *,curr
54 found=.true.
55 type is (integer(kind=int_b))
56 print *,curr
57 found=.true.
58 type is (character(*))
59 print *,curr
60 found=.true.
61 end select
62
63 if (.not. found) then
64 print *, "not supported type for display"
65 end if
66
67 call this%next()
68end do
69call this%rewind()
70end subroutine displaymix
72
73!> get class(*) pointed by iterator
74function currentmix(this)
75class(mixlist),intent(inout) :: this
76class(*), pointer :: currentmix
77currentmix => this%currentpoli()
78end function currentmix
79
80
81end module list_mix
82
83!>\example example_list.F03
84!!\brief Sample program to demostrate the list* module.
85!!
86!! This modules port lists to fortran 2003.
Definition of constants to be used for declaring variables of a desired type.
Definition kinds.F90:245
abstract class to use lists in fortran 2003.
class to use lists in fortran 2003.
Definition list_mix.F03:58
Abstract implementation of doubly-linked list.
Non type specific implementation of doubly-linked list.
Definition list_mix.F03:65

Generated with Doxygen.