subroutinepush_backprivate
subroutine push_back(stack, n, text)
Put text back on the stack of chunks.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| stack | type(string_t) | inout | allocatabledimension(:) | the chunks, the next one last |
| n | integer | inout | how many there are | |
| text | character(len=*) | in | the chunk |
Source
Show the code
subroutine push_back(stack, n, text)
type(string_t), allocatable, intent(inout) :: stack(:) !! the chunks, the next one last
integer, intent(inout) :: n !! how many there are
character(len=*), intent(in) :: text !! the chunk
type(string_t), allocatable :: grown(:)
integer :: k
if (n == size(stack)) then
allocate (grown(2*n + 4))
do k = 1, n
call move_alloc(stack(k)%s, grown(k)%s)
end do
call move_alloc(grown, stack)
end if
n = n + 1
stack(n)%s = text
end subroutine push_back