libsim Versione 7.2.6
list_byte.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!!
17module list_byte
19 use kinds
20 private
21 public :: bytelist
22!> Byte specific implementation of doubly-linked list
23!!
24!! extend list_abstract::list
25 type, extends(list) :: bytelist
26#ifdef DOXYGEN
27 integer::none ! doxigen workaround: if missed do not show procedure
28#endif
29 contains
30! procedure :: addByte !< add byte in list
31 procedure :: current => currentbyte !< get byte pointed by iterator
32 procedure :: display => displaybyte !< print the byte list
33! generic :: add => addByte
34 end type bytelist
35
36contains
37
38!> Print the byte list
39subroutine displaybyte(this)
40class(byteList),intent(inout) :: this
41
42call this%rewind()
43do while(this%element())
44 print *,"index:",this%currentindex()," value:", this%current()
45 call this%next()
46end do
47end subroutine displaybyte
48
49!!$ subroutine addByte(this, value)
50!!$ class(byteList) :: this
51!!$ byte value
52!!$ class(*), allocatable :: v
53!!$
54!!$ allocate(v,source=value)
55!!$ call this%addvalue(v)
56!!$
57!!$ end subroutine addByte
59
60!> get byte pointed by iterator
61integer(kind=int_b) function currentbyte(this)
62class(byteList) :: this
63class(*), pointer :: v
64
65v => this%currentpoli()
66select type(v)
67type is (integer(kind=int_b))
68 currentbyte = v
69end select
70end function currentbyte
71
72end module list_byte
Definition of constants to be used for declaring variables of a desired type.
Definition kinds.F90:245
abstract class to use lists in fortran 2003.
class to use lists in fortran 2003.
Definition list_byte.F03:58
Abstract implementation of doubly-linked list.
Byte specific implementation of doubly-linked list.
Definition list_byte.F03:66

Generated with Doxygen.