libsim Versione 7.2.6
list_doubleprecision.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!!
19 private
20 public :: doubleprecisionlist
21!> Double precision specific implementation of doubly-linked list
22!!
23!! extend list_abstract::list
24 type, extends(list) :: doubleprecisionlist
25#ifdef DOXYGEN
26 integer::none ! doxigen workaround: if missed do not show procedure
27#endif
28 contains
29! procedure :: addDoubleprecision !< add doubleprecision in list
30 procedure :: current => currentdoubleprecision !< get doubleprecision pointed by iterator
31 procedure :: display => displaydoubleprecision !< print the doubleprecision list
32! generic :: add => addDoubleprecision
33 end type doubleprecisionlist
34
35contains
36
37!> Print the double precision list
38subroutine displaydoubleprecision(this)
39class(doubleprecisionList),intent(inout) :: this
40
41call this%rewind()
42do while(this%element())
43 print *,"index:",this%currentindex()," value:", this%current()
44 call this%next()
45end do
46end subroutine displaydoubleprecision
47
48!!$ subroutine addDoubleprecision(this, value)
49!!$ class(doubleprecisionList) :: this
50!!$ doubleprecision value
51!!$ class(*), allocatable :: v
52!!$
53!!$ allocate(v,source=value)
54!!$ call this%addvalue(v)
55!!$
56!!$ end subroutine addDoubleprecision
57
59!> get double precision pointed by iterator
60doubleprecision function currentdoubleprecision(this)
61class(doubleprecisionList) :: this
62class(*), pointer :: v
63
64v => this%currentpoli()
65select type(v)
66type is (doubleprecision)
67 currentdoubleprecision = v
68end select
69end function currentdoubleprecision
70
abstract class to use lists in fortran 2003.
class to use lists in fortran 2003.
Abstract implementation of doubly-linked list.
Double precision specific implementation of doubly-linked list.

Generated with Doxygen.