Append one element. ERROR_ALLOC if storage cannot be grown, in which
case the vector is unchanged.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_string_t), | intent(inout) | :: | self | |||
| type(string_type), | intent(in) | :: | value | |||
| type(error_t), | intent(inout), | optional | :: | err |
pure subroutine vec_string_push_back(self, value, err) !! Append one element. `ERROR_ALLOC` if storage cannot be grown, in which !! case the vector is unchanged. class(vector_string_t), intent(inout) :: self type(string_type), 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_string_t: already holds PIC_VECTOR_MAX_CAPACITY elements.") return end if call vec_string_grow(self, self%n_items + 1, err) if (self%n_items + 1 > vec_string_capacity(self)) return self%n_items = self%n_items + 1 self%items(self%n_items) = value end subroutine vec_string_push_back