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