append_i32_buffer Subroutine

public subroutine append_i32_buffer(buf, n_used, capacity, value)

整数バッファへ値を追加し、必要なら容量を拡張する。

Arguments

Type IntentOptional Attributes Name
integer(kind=i32), intent(inout), allocatable :: buf(:)
integer(kind=i32), intent(inout) :: n_used

使用中要素数。

integer(kind=i32), intent(inout) :: capacity

使用中要素数。 確保容量。

integer(kind=i32), intent(in) :: value

追加する値。


Called by

proc~~append_i32_buffer~~CalledByGraph proc~append_i32_buffer append_i32_buffer proc~core_build_plan_impl core_build_plan_impl proc~core_build_plan_impl->proc~append_i32_buffer

Source Code

  subroutine append_i32_buffer(buf, n_used, capacity, value)
    integer(i32), allocatable, intent(inout) :: buf(:)
    integer(i32), intent(inout) :: n_used, capacity
    integer(i32), intent(in) :: value
    integer(i32), allocatable :: tmp(:)
    integer(i32) :: new_capacity

    if (n_used >= capacity) then
      new_capacity = max(capacity*2_i32, capacity + 32_i32)
      allocate (tmp(new_capacity))
      tmp = 0_i32
      if (n_used > 0_i32) tmp(1:n_used) = buf(1:n_used)
      call move_alloc(tmp, buf)
      capacity = new_capacity
    end if
    n_used = n_used + 1_i32
    buf(n_used) = value
  end subroutine append_i32_buffer