Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(nodeStack_t), | intent(inout) | :: | self |
function pop(self) result(o)
class(nodeStack_t),intent(inout)::self
class(node_t),allocatable::o
integer::k
if(self%D==0) then
stop 'Tried to pop with empty stack'
end if
allocate(o,source=self%levels(1)%node)
do k=1,min(self%D,self%N-1)
self%levels(k) = self%levels(k+1)
end do
if(self%N==self%D) then
if(allocated(self%levels(self%N)%node)) deallocate(self%levels(self%N)%node)
end if
self%D = self%D-1
end function pop