1 | module m_dom_nodelist |
---|
2 | |
---|
3 | use m_dom_types |
---|
4 | |
---|
5 | private |
---|
6 | |
---|
7 | public :: item |
---|
8 | public :: getLength |
---|
9 | public :: append |
---|
10 | |
---|
11 | interface append |
---|
12 | module procedure append_nl |
---|
13 | end interface |
---|
14 | |
---|
15 | interface item |
---|
16 | module procedure item_nl |
---|
17 | end interface |
---|
18 | |
---|
19 | interface getLength |
---|
20 | module procedure getLength_nl |
---|
21 | end interface |
---|
22 | |
---|
23 | CONTAINS |
---|
24 | |
---|
25 | !----------------------------------------------------------- |
---|
26 | ! METHODS FOR NODELISTS |
---|
27 | !----------------------------------------------------------- |
---|
28 | function item_nl(nodeList, i) |
---|
29 | |
---|
30 | integer, intent(in) :: i |
---|
31 | type(fnodeList), pointer :: nodeList |
---|
32 | type(fnode), pointer :: item_nl |
---|
33 | |
---|
34 | type(flistNode), pointer :: lp |
---|
35 | integer :: n |
---|
36 | |
---|
37 | item_nl => null() ! In case there is no such item |
---|
38 | if (.not. associated(nodeList)) RETURN |
---|
39 | |
---|
40 | lp => nodeList%head |
---|
41 | n = -1 |
---|
42 | do |
---|
43 | if (.not. associated(lp)) exit |
---|
44 | n = n + 1 |
---|
45 | if (n == i) then |
---|
46 | item_nl => lp%node |
---|
47 | exit |
---|
48 | endif |
---|
49 | lp => lp%next |
---|
50 | enddo |
---|
51 | |
---|
52 | end function item_nl |
---|
53 | |
---|
54 | !----------------------------------------------------------- |
---|
55 | |
---|
56 | function getLength_nl(nodeList) |
---|
57 | |
---|
58 | type(fnodeList), pointer :: nodeList |
---|
59 | integer :: getLength_nl |
---|
60 | |
---|
61 | if (.not. associated(nodeList)) then |
---|
62 | getLength_nl = 0 |
---|
63 | else |
---|
64 | getLength_nl = nodeList % length |
---|
65 | endif |
---|
66 | |
---|
67 | end function getLength_nl |
---|
68 | |
---|
69 | subroutine append_nl(nodeList,node) |
---|
70 | type(fnodeList), pointer :: nodeList |
---|
71 | type(fnode), pointer :: node |
---|
72 | |
---|
73 | if (.not. associated(nodeList)) then |
---|
74 | allocate(nodeList) |
---|
75 | nodelist%length = 1 |
---|
76 | allocate(nodelist%head) |
---|
77 | nodelist%head%node => node |
---|
78 | nodelist%tail => nodelist%head |
---|
79 | else |
---|
80 | allocate(nodelist%tail%next) |
---|
81 | nodelist%tail%next%node => node |
---|
82 | nodelist%tail => nodelist%tail%next |
---|
83 | nodelist%length = nodelist%length + 1 |
---|
84 | endif |
---|
85 | |
---|
86 | end subroutine append_nl |
---|
87 | |
---|
88 | end module m_dom_nodelist |
---|
89 | |
---|