libsim Versione 7.2.6
list_character.F03
1!> \brief class to use character lists in fortran 2003 WARNING !!!! CHAR LEN IS FIXED TO listcharmaxlen.
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_character
20 private
21 public :: characterlist, toarray_charl
22!> Character specific implementation of doubly-linked list
23!!
24!! extend list_abstract::list
25 type, extends(list) :: characterlist
26#ifdef DOXYGEN
27 integer::none ! doxigen workaround: if missed do not show procedure
28#endif
29 contains
30! procedure :: addCharacter !< add character in list
31 procedure :: current => currentcharacter !< get character pointed by iterator
32 procedure :: display => displaycharacter !< print the character list
33! generic :: add => addCharacter
34 end type characterlist
35
36contains
37
38!> Print the character list
39subroutine displaycharacter(this)
40class(characterList) :: this
41
42call this%rewind()
43do while(this%element())
44
45 print *,"index:",this%currentindex()," value:", trim(this%current())
46 call this%next()
47end do
48end subroutine displaycharacter
49
50!!$ subroutine addCharacter(this, value)
51!!$ class(characterList) :: this
52!!$ character value
53!!$ class(*), allocatable :: v
54!!$
55!!$ allocate(v,source=value)
56!!$ call this%addvalue(v)
57!!$
58!!$ end subroutine addCharacter
59
60
61!> get character pointed by iterator
62function currentcharacter(this)
63character(len=listcharmaxlen) :: currentCharacter
64class(characterList) :: this
65
66currentcharacter = this%currentpoli()
67
68end function currentcharacter
69
70
71!> /brief Return an array of char from
72function toarray_charl(this)
73character(len=listcharmaxlen),allocatable :: toarray_charl(:) !< array
74type(characterlist) :: this !< list of char
75
76integer :: i
77
78allocate (toarray_charl(this%countelements()))
79
80call this%rewind()
81i=0
82do while(this%element())
83 i=i+1
84 toarray_charl(i) =this%current()
85 call this%next()
86end do
87end function toarray_charl
88
89
90
91end module list_character
like abstract class to use character lists in fortran 2003 (gnu gcc 4.8 do not work with character(le...
class to use character lists in fortran 2003 WARNING !
class to manage links for lists in fortran 2003.
Abstract implementation of doubly-linked list.
Character specific implementation of doubly-linked list.

Generated with Doxygen.