simplified tNode_get_byKey_asIndex and tNode_getKey_byIndex; syntax polishing
This commit is contained in:
parent
4edf8e1c6c
commit
c0620037a1
|
@ -435,13 +435,12 @@ function tNode_get_byIndex(self,i) result(node)
|
|||
integer :: j
|
||||
|
||||
self_ => self%asList()
|
||||
item => self_%first
|
||||
|
||||
if(i < 1 .or. i > self_%length) call IO_error(150,ext_msg='tNode_get_byIndex')
|
||||
|
||||
j = 1
|
||||
item => self_%first
|
||||
do while(j<i)
|
||||
do j = 2,i
|
||||
item => item%next
|
||||
j = j + 1
|
||||
enddo
|
||||
node => item%node
|
||||
|
||||
|
@ -615,14 +614,10 @@ function tNode_getKey_byIndex(self,i) result(key)
|
|||
|
||||
dict => self%asDict()
|
||||
item => dict%first
|
||||
do j = 1, dict%length
|
||||
if(j == i) then
|
||||
key = item%key
|
||||
exit
|
||||
else
|
||||
do j = 1, min(i,dict%length)-1
|
||||
item => item%next
|
||||
endif
|
||||
enddo
|
||||
key = item%key
|
||||
|
||||
end function tNode_getKey_byIndex
|
||||
|
||||
|
@ -954,23 +949,18 @@ function tNode_get_byKey_asIndex(self,key) result(keyIndex)
|
|||
character(len=*), intent(in) :: key
|
||||
|
||||
integer :: keyIndex
|
||||
integer :: i
|
||||
type(tDict), pointer :: dict
|
||||
type(tItem), pointer :: item
|
||||
|
||||
dict => self%asDict()
|
||||
item => dict%first
|
||||
keyIndex = -1
|
||||
do i = 1, dict%length
|
||||
if(key == item%key) then
|
||||
keyIndex = i
|
||||
exit
|
||||
else
|
||||
keyIndex = 1
|
||||
do while (associated(item%next) .and. item%key /= key)
|
||||
item => item%next
|
||||
endif
|
||||
keyIndex = keyIndex+1
|
||||
enddo
|
||||
|
||||
if(keyIndex == -1) call IO_error(140,ext_msg=key)
|
||||
if (item%key /= key) call IO_error(140,ext_msg=key)
|
||||
|
||||
|
||||
end function tNode_get_byKey_asIndex
|
||||
|
@ -1254,7 +1244,7 @@ subroutine tDict_set(self,key,node)
|
|||
if (item%key == key) exit
|
||||
item => item%next
|
||||
end do searchExisting
|
||||
if (.not. item%key == key) then
|
||||
if (item%key /= key) then
|
||||
allocate(item%next)
|
||||
item => item%next
|
||||
self%length = self%length + 1
|
||||
|
|
Loading…
Reference in New Issue