Append one element. ERROR_ALLOC if storage cannot be grown, in which
case the vector is unchanged.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_int64_t), | intent(inout) | :: | self | |||
| integer(kind=int64), | intent(in) | :: | value | |||
| type(error_t), | intent(inout), | optional | :: | err |
pure subroutine vec_int64_push_back(self, value, err) !! Append one element. `ERROR_ALLOC` if storage cannot be grown, in which !! case the vector is unchanged. class(vector_int64_t), intent(inout) :: self integer(int64), intent(in) :: value type(error_t), intent(inout), optional :: err ! Checked before adding, not after: `n_items + 1` at the maximum wraps ! negative, and every downstream test would then read as "plenty of ! room" while the append walked off the end of the array. if (self%n_items >= PIC_VECTOR_MAX_CAPACITY) then call error_raise(err, ERROR_ALLOC, & "vector_int64_t: already holds PIC_VECTOR_MAX_CAPACITY elements.") return end if call vec_int64_grow(self, self%n_items + 1, err) if (self%n_items + 1 > vec_int64_capacity(self)) return self%n_items = self%n_items + 1 self%items(self%n_items) = value end subroutine vec_int64_push_back