Growable array of type(string_type).
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| type(string_type), | private, | allocatable | :: | items(:) |
Backing storage. Only |
||
| integer(kind=default_int), | private | :: | n_items | = | 0 |
Number of live elements. Always |
Append many elements, growing once rather than once per element.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_string_t), | intent(inout) | :: | self | |||
| type(string_type), | intent(in) | :: | values(:) | |||
| type(error_t), | intent(inout), | optional | :: | err |
A copy holding exactly size() elements.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_string_t), | intent(in) | :: | self |
Read element index, 1-based. ERROR_BOUNDS when out of range.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_string_t), | intent(in) | :: | self | |||
| integer(kind=default_int), | intent(in) | :: | index | |||
| type(string_type), | intent(out) | :: | value | |||
| type(error_t), | intent(inout), | optional | :: | err |
Elements that fit before the next reallocation.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_string_t), | intent(in) | :: | self |
Drop every element but keep the allocated storage, so a vector reused across iterations of an outer loop stops reallocating.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_string_t), | intent(inout) | :: | self |
Release all storage and reset to the empty state.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_string_t), | intent(inout) | :: | self |
Element index with no bounds check, for hot loops that have already
established the range. Reading outside 1:size() is undefined.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_string_t), | intent(in) | :: | self | |||
| integer(kind=default_int), | intent(in) | :: | index |
.true. when there are no live elements.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_string_t), | intent(in) | :: | self |
Remove and return the last element. ERROR_BOUNDS when empty, in
which case the vector is unchanged.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_string_t), | intent(inout) | :: | self | |||
| type(string_type), | intent(out) | :: | value | |||
| type(error_t), | intent(inout), | optional | :: | err |
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 |
Make room for at least n elements. size() is unchanged.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_string_t), | intent(inout) | :: | self | |||
| integer(kind=default_int), | intent(in) | :: | n | |||
| type(error_t), | intent(inout), | optional | :: | err |
Set the length to n, padding with fill when growing and dropping
elements from the end when shrinking.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_string_t), | intent(inout) | :: | self | |||
| integer(kind=default_int), | intent(in) | :: | n | |||
| type(string_type), | intent(in) | :: | fill | |||
| type(error_t), | intent(inout), | optional | :: | err |
Overwrite element index, 1-based. ERROR_BOUNDS when out of range;
this never extends the vector, use push_back or resize for that.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_string_t), | intent(inout) | :: | self | |||
| integer(kind=default_int), | intent(in) | :: | index | |||
| type(string_type), | intent(in) | :: | value | |||
| type(error_t), | intent(inout), | optional | :: | err |
Release capacity beyond size().
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_string_t), | intent(inout) | :: | self | |||
| type(error_t), | intent(inout), | optional | :: | err |
Number of live elements.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_string_t), | intent(in) | :: | self |
Hand the storage over to array, exactly sized, without copying the
elements. The vector is left empty and without storage.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_string_t), | intent(inout) | :: | self | |||
| type(string_type), | intent(out), | allocatable | :: | array(:) | ||
| type(error_t), | intent(inout), | optional | :: | err |
type :: vector_string_t !! Growable array of type(string_type). integer(default_int), private :: n_items = 0 !! Number of live elements. Always `0 <= n_items <= capacity()`. type(string_type), allocatable, private :: items(:) !! Backing storage. Only `items(1:n_items)` is meaningful; the rest is !! spare capacity whose contents are unspecified. contains procedure :: push_back => vec_string_push_back procedure :: append => vec_string_append procedure :: pop_back => vec_string_pop_back procedure :: at => vec_string_at procedure :: set => vec_string_set procedure :: get_unchecked => vec_string_get_unchecked procedure :: size => vec_string_size procedure :: capacity => vec_string_capacity procedure :: is_empty => vec_string_is_empty procedure :: reserve => vec_string_reserve procedure :: resize => vec_string_resize procedure :: clear => vec_string_clear procedure :: shrink_to_fit => vec_string_shrink_to_fit procedure :: as_array => vec_string_as_array procedure :: take => vec_string_take procedure :: destroy => vec_string_destroy end type vector_string_t