libsim Versione 7.2.6
|
◆ currentcharacter()
get character pointed by iterator Definizione alla linea 103 del file list_character.F03. 104!> \brief class to use character lists in fortran 2003 WARNING !!!! CHAR LEN IS FIXED TO listcharmaxlen.
105!!
106!! Linked data structure is a data structure which
107!! consists of a set of data records (nodes) linked together and organized by references .
108!!
109!! A doubly-linked list is a linked data structure that consists of a set
110!! of sequentially linked records called nodes. Each node contains two
111!! fields, called links, that are references to the previous and to the
112!! next node in the sequence of nodes. The beginning and ending nodes'
113!! previous and next links, respectively, point to some kind of
114!! terminator.
115!!
116!! The program example is the better starting point:
117!!\include example_list.F03
118!!\ingroup base
119!!
123 private
125!> Character specific implementation of doubly-linked list
126!!
127!! extend list_abstract::list
129#ifdef DOXYGEN
130 integer::none ! doxigen workaround: if missed do not show procedure
131#endif
132 contains
133! procedure :: addCharacter !< add character in list
134 procedure :: current => currentcharacter !< get character pointed by iterator
135 procedure :: display => displaycharacter !< print the character list
136! generic :: add => addCharacter
138
139contains
140
141!> Print the character list
142subroutine displaycharacter(this)
143class(characterList) :: this
144
145call this%rewind()
146do while(this%element())
147
148 print *,"index:",this%currentindex()," value:", trim(this%current())
149 call this%next()
150end do
151end subroutine displaycharacter
152
153!!$ subroutine addCharacter(this, value)
154!!$ class(characterList) :: this
155!!$ character value
156!!$ class(*), allocatable :: v
157!!$
158!!$ allocate(v,source=value)
159!!$ call this%addvalue(v)
160!!$
161!!$ end subroutine addCharacter
162
163
164!> get character pointed by iterator
165function currentcharacter(this)
166character(len=listcharmaxlen) :: currentCharacter
167class(characterList) :: this
168
169currentcharacter = this%currentpoli()
170
171end function currentcharacter
172
173
174!> /brief Return an array of char from
175function toarray_charl(this)
176character(len=listcharmaxlen),allocatable :: toarray_charl(:) !< array
177type(characterlist) :: this !< list of char
178
179integer :: i
180
181allocate (toarray_charl(this%countelements()))
182
183call this%rewind()
184i=0
185do while(this%element())
186 i=i+1
187 toarray_charl(i) =this%current()
188 call this%next()
189end do
190end function toarray_charl
191
192
193
like abstract class to use character lists in fortran 2003 (gnu gcc 4.8 do not work with character(le... Definition list_abstractforchar.F03:48 class to use character lists in fortran 2003 WARNING ! Definition list_character.F03:58 Abstract implementation of doubly-linked list. Definition list_abstractforchar.F03:57 Character specific implementation of doubly-linked list. Definition list_character.F03:66 |