nfa__reallocate_transition_forward Subroutine

private pure subroutine nfa__reallocate_transition_forward(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_forward (self)
      implicit none
      class(nfa_state_node_t), intent(inout) :: self
      type(nfa_transition_t), allocatable :: tmp(:)
      integer :: siz, j
      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%forward)) then
         siz = size(self%forward, dim=1)
         call move_alloc(self%forward, tmp)
      else
         siz = 0
      end  if

      prev_count = self%alloc_count_f
      self%alloc_count_f = prev_count + 1

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

      allocate(self%forward(1:new_part_end))

      if (allocated(tmp)) then
         do j = 1, siz
            self%forward(j) = tmp(j)
         end do
      end if

      self%forward(1:new_part_end)%own_j = &
         [(j, j= 1, new_part_end)]

   end subroutine nfa__reallocate_transition_forward