fixed_array_int_pop_back Subroutine

private pure subroutine fixed_array_int_pop_back(self, value, err)

Remove and return the last element (LIFO). On an empty array value is set to zero and err is set to ERROR_VALIDATION. On success err is left untouched.

Type Bound

fixed_array_int_t

Arguments

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

Calls

proc~~fixed_array_int_pop_back~~CallsGraph proc~fixed_array_int_pop_back fixed_array_int_t%fixed_array_int_pop_back proc~error_set error_t%error_set proc~fixed_array_int_pop_back->proc~error_set

Source Code

   pure subroutine fixed_array_int_pop_back(self, value, err)
      !! Remove and return the last element (LIFO). On an empty array
      !! `value` is set to zero and `err` is set to `ERROR_VALIDATION`.
      !! On success `err` is left untouched.
      class(fixed_array_int_t), intent(inout) :: self
      integer(default_int), intent(out) :: value
      type(error_t), intent(inout) :: err

      if (self%n_items <= 0_default_int) then
         value = 0_default_int
         call err%set(ERROR_VALIDATION, MSG_UNDERFLOW)
         return
      end if

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