Growable array of integer(int32).
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=int32), | 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_int32_t), | intent(inout) | :: | self | |||
| integer(kind=int32), | intent(in) | :: | values(:) | |||
| type(error_t), | intent(inout), | optional | :: | err |
A copy holding exactly size() elements.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_int32_t), | intent(in) | :: | self |
Read element index, 1-based. ERROR_BOUNDS when out of range.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_int32_t), | intent(in) | :: | self | |||
| integer(kind=default_int), | intent(in) | :: | index | |||
| integer(kind=int32), | intent(out) | :: | value | |||
| type(error_t), | intent(inout), | optional | :: | err |
Elements that fit before the next reallocation.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_int32_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_int32_t), | intent(inout) | :: | self |
Release all storage and reset to the empty state.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_int32_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_int32_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_int32_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_int32_t), | intent(inout) | :: | self | |||
| integer(kind=int32), | 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_int32_t), | intent(inout) | :: | self | |||
| integer(kind=int32), | 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_int32_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_int32_t), | intent(inout) | :: | self | |||
| integer(kind=default_int), | intent(in) | :: | n | |||
| integer(kind=int32), | 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_int32_t), | intent(inout) | :: | self | |||
| integer(kind=default_int), | intent(in) | :: | index | |||
| integer(kind=int32), | intent(in) | :: | value | |||
| type(error_t), | intent(inout), | optional | :: | err |
Release capacity beyond size().
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_int32_t), | intent(inout) | :: | self | |||
| type(error_t), | intent(inout), | optional | :: | err |
Number of live elements.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_int32_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_int32_t), | intent(inout) | :: | self | |||
| integer(kind=int32), | intent(out), | allocatable | :: | array(:) | ||
| type(error_t), | intent(inout), | optional | :: | err |
type :: vector_int32_t !! Growable array of integer(int32). integer(default_int), private :: n_items = 0 !! Number of live elements. Always `0 <= n_items <= capacity()`. integer(int32), 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_int32_push_back procedure :: append => vec_int32_append procedure :: pop_back => vec_int32_pop_back procedure :: at => vec_int32_at procedure :: set => vec_int32_set procedure :: get_unchecked => vec_int32_get_unchecked procedure :: size => vec_int32_size procedure :: capacity => vec_int32_capacity procedure :: is_empty => vec_int32_is_empty procedure :: reserve => vec_int32_reserve procedure :: resize => vec_int32_resize procedure :: clear => vec_int32_clear procedure :: shrink_to_fit => vec_int32_shrink_to_fit procedure :: as_array => vec_int32_as_array procedure :: take => vec_int32_take procedure :: destroy => vec_int32_destroy end type vector_int32_t