nfa__reallocate_transition_backward Subroutine

private pure subroutine nfa__reallocate_transition_backward(self)

Type Bound

nfa_state_node_t

Arguments

Type IntentOptional Attributes Name
class(nfa_state_node_t), intent(inout) :: self

Source Code

   pure subroutine nfa__reallocate_transition_backward (self)
      implicit none
      class(nfa_state_node_t), intent(inout) :: self
      type(nfa_transition_t), allocatable :: tmp(:)
      integer :: siz, jj
      integer :: prev_count, new_part_begin, new_part_end

      siz = 0
      prev_count = 0
      new_part_begin = 0
      new_part_end = 0

      if (allocated(self%backward)) then
         siz = size(self%backward, dim=1)
         call move_alloc(self%backward, tmp)
      else
         siz = 0
      end  if

      prev_count = self%alloc_count_b
      self%alloc_count_b = prev_count + 1

      new_part_begin = (siz) + 1
      new_part_end =  NFA_TRANSITION_UNIT * 2**self%alloc_count_b

      allocate(self%backward(1:new_part_end))

      if(allocated(tmp)) self%backward(1:siz) = tmp(1:siz)

      self%backward(new_part_begin:new_part_end)%own_j = &
         [(jj, jj= new_part_begin, new_part_end)]

   end subroutine nfa__reallocate_transition_backward