vec_int32_pop_back Subroutine

private pure subroutine vec_int32_pop_back(self, value, err)

Remove and return the last element. ERROR_BOUNDS when empty, in which case the vector is unchanged.

Type Bound

vector_int32_t

Arguments

Type IntentOptional Attributes Name
class(vector_int32_t), intent(inout) :: self
integer(kind=int32), intent(out) :: value
type(error_t), intent(inout), optional :: err

Calls

proc~~vec_int32_pop_back~~CallsGraph proc~vec_int32_pop_back vector_int32_t%vec_int32_pop_back proc~error_raise error_raise proc~vec_int32_pop_back->proc~error_raise proc~error_set error_t%error_set proc~error_raise->proc~error_set

Source Code

   pure subroutine vec_int32_pop_back(self, value, err)
      !! Remove and return the last element. `ERROR_BOUNDS` when empty, in
      !! which case the vector is unchanged.
      class(vector_int32_t), intent(inout) :: self
      integer(int32), intent(out) :: value
      type(error_t), intent(inout), optional :: err

      if (self%n_items <= 0) then
         call error_raise(err, ERROR_BOUNDS, "vector_int32_t: pop_back on an empty vector.")
         return
      end if

      value = self%items(self%n_items)
      self%n_items = self%n_items - 1
   end subroutine vec_int32_pop_back