libsim Versione 7.2.6

◆ toarray_integerl()

integer function, dimension(:), allocatable, public toarray_integerl ( class(integerlist) this)

/brief Return an array of integer from list

Restituisce
array
Parametri
thislist of integer

Definizione alla linea 114 del file list_integer.F03.

115!> \brief class to use lists in fortran 2003.
116!!
117!! Linked data structure is a data structure which
118!! consists of a set of data records (nodes) linked together and organized by references .
119!!
120!! A doubly-linked list is a linked data structure that consists of a set
121!! of sequentially linked records called nodes. Each node contains two
122!! fields, called links, that are references to the previous and to the
123!! next node in the sequence of nodes. The beginning and ending nodes'
124!! previous and next links, respectively, point to some kind of
125!! terminator.
126!!
127!! The program example is the better starting point:
128!!\include example_list.F03
129!!\ingroup base
130!!
131module list_integer
132 use list_abstract
133 private
134 public :: integerlist, toarray_integerl
135
136!> Integer specific implementation of doubly-linked list
137!!
138!! extend list_abstract::list
139 type, extends(list) :: integerlist
140#ifdef DOXYGEN
141 integer::none ! doxigen workaround: if missed do not show procedure
142#endif
143 contains
144! procedure :: addInteger !< add integer in list
145 procedure :: current => currentinteger !< get integer pointed by iterator
146 procedure :: display => displayinteger !< print the integer list
147 procedure :: toarray => toarray_integerl !< convert to array the integer list
148! generic :: add => addInteger
149 end type integerlist
150
151contains
152
153!> Print the integer list
154subroutine displayinteger(this)
155class(integerList),intent(inout) :: this
156
157call this%rewind()
158do while(this%element())
159 print *,"index:",this%currentindex()," value:", this%current()
160 call this%next()
161end do
162end subroutine displayinteger
163
164!!$ subroutine addInteger(this, value)
165!!$ class(integerList) :: thisb
166!!$ integer value
167!!$ class(*), allocatable :: v
168!!$
169!!$ allocate(v,source=value)
170!!$ call this%addvalue(v)
171!!$
172!!$ end subroutine addInteger
173
174!> get integer pointed by iterator
175integer function currentinteger(this)
176class(integerList) :: this
177class(*), pointer :: v
178
179v => this%currentpoli()
180select type(v)
181type is (integer)
182 currentinteger = v
183end select
184end function currentinteger
185
186!> /brief Return an array of integer from list
187function toarray_integerl(this)
188integer,allocatable :: toarray_integerl(:) !< array
189class(integerlist) :: this !< list of integer
190
191integer :: i
192
193allocate (toarray_integerl(this%countelements()))
194
195call this%rewind()
196i=0
197do while(this%element())
198 i=i+1
199 toarray_integerl(i) =this%current()
200 call this%next()
201end do
202end function toarray_integerl
203
204
205end module list_integer
abstract class to use lists in fortran 2003.
class to use lists in fortran 2003.
Abstract implementation of doubly-linked list.
Integer specific implementation of doubly-linked list.

Generated with Doxygen.