Growable vectors: push_back, pop_back, at, and amortised O(1)
growth over heap storage.
pic_fixed_arraypic_fixed_array stores its elements inside the object, never touches
the heap, and stops at PIC_FIXED_ARRAY_CAPACITY. Use it in hot loops
and inside OpenMP/OpenACC regions.
pic_vector grows without a compile-time bound, at the cost of
allocating. Use it where the final length is not known until the input
has been read. The two share a method vocabulary on purpose, so moving
between them is mostly a type change – but not entirely, and the
differences are the kind that fail quietly:
ERROR_BOUNDS here and
ERROR_VALIDATION in pic_fixed_array. Code that branches on the code
stops branching after the swap.pic_fixed_array sets value to zero when at or pop_back fails;
here value is intent(out) and left undefined, so a caller that
ignores err reads something deterministic before the swap and not
after.vector_int_t. fixed_array_int_t holds default_int,
which changes width with PIC_DEFAULT_INT8; see below.There is no vector_int_t following default_int: the same source
would mean a 32-bit container in one build and a 64-bit one in the
other, and anything serialized from it would not survive the switch.
Sizes and indices are default_int, as everywhere else in PIC.
Only 1:size() of the backing array is meaningful. Exposing it would
let v%items(v%size() + 1) compile and read spare capacity. The two
cases that need to avoid a copy are served directly: take moves the
storage out, and get_unchecked skips the bounds test.
Usage: type(vector_int32_t) :: v type(error_t) :: err integer(int32), allocatable :: final(:)
call v%push_back(42_int32, err)
call v%take(final) ! v is now empty, final is exactly sized
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=default_int), | public, | parameter | :: | PIC_VECTOR_MAX_CAPACITY | = | huge(0_default_int) |
Largest representable capacity. Growth clamps here rather than
overflowing |
| integer(kind=default_int), | public, | parameter | :: | PIC_VECTOR_MIN_CAPACITY | = | 8_default_int |
Capacity of a vector after its first |
Growable array of real(dp).
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=dp), | private, | allocatable | :: | items(:) |
Backing storage. Only |
||
| integer(kind=default_int), | private | :: | n_items | = | 0 |
Number of live elements. Always |
| procedure, public :: append => vec_dp_append | |
| procedure, public :: as_array => vec_dp_as_array | |
| procedure, public :: at => vec_dp_at | |
| procedure, public :: capacity => vec_dp_capacity | |
| procedure, public :: clear => vec_dp_clear | |
| procedure, public :: destroy => vec_dp_destroy | |
| procedure, public :: get_unchecked => vec_dp_get_unchecked | |
| procedure, public :: is_empty => vec_dp_is_empty | |
| procedure, public :: pop_back => vec_dp_pop_back | |
| procedure, public :: push_back => vec_dp_push_back | |
| procedure, public :: reserve => vec_dp_reserve | |
| procedure, public :: resize => vec_dp_resize | |
| procedure, public :: set => vec_dp_set | |
| procedure, public :: shrink_to_fit => vec_dp_shrink_to_fit | |
| procedure, public :: size => vec_dp_size | |
| procedure, public :: take => vec_dp_take |
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 |
| procedure, public :: append => vec_int32_append | |
| procedure, public :: as_array => vec_int32_as_array | |
| procedure, public :: at => vec_int32_at | |
| procedure, public :: capacity => vec_int32_capacity | |
| procedure, public :: clear => vec_int32_clear | |
| procedure, public :: destroy => vec_int32_destroy | |
| procedure, public :: get_unchecked => vec_int32_get_unchecked | |
| procedure, public :: is_empty => vec_int32_is_empty | |
| procedure, public :: pop_back => vec_int32_pop_back | |
| procedure, public :: push_back => vec_int32_push_back | |
| procedure, public :: reserve => vec_int32_reserve | |
| procedure, public :: resize => vec_int32_resize | |
| procedure, public :: set => vec_int32_set | |
| procedure, public :: shrink_to_fit => vec_int32_shrink_to_fit | |
| procedure, public :: size => vec_int32_size | |
| procedure, public :: take => vec_int32_take |
Growable array of integer(int64).
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=int64), | private, | allocatable | :: | items(:) |
Backing storage. Only |
||
| integer(kind=default_int), | private | :: | n_items | = | 0 |
Number of live elements. Always |
| procedure, public :: append => vec_int64_append | |
| procedure, public :: as_array => vec_int64_as_array | |
| procedure, public :: at => vec_int64_at | |
| procedure, public :: capacity => vec_int64_capacity | |
| procedure, public :: clear => vec_int64_clear | |
| procedure, public :: destroy => vec_int64_destroy | |
| procedure, public :: get_unchecked => vec_int64_get_unchecked | |
| procedure, public :: is_empty => vec_int64_is_empty | |
| procedure, public :: pop_back => vec_int64_pop_back | |
| procedure, public :: push_back => vec_int64_push_back | |
| procedure, public :: reserve => vec_int64_reserve | |
| procedure, public :: resize => vec_int64_resize | |
| procedure, public :: set => vec_int64_set | |
| procedure, public :: shrink_to_fit => vec_int64_shrink_to_fit | |
| procedure, public :: size => vec_int64_size | |
| procedure, public :: take => vec_int64_take |
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 |
| procedure, public :: append => vec_string_append | |
| procedure, public :: as_array => vec_string_as_array | |
| procedure, public :: at => vec_string_at | |
| procedure, public :: capacity => vec_string_capacity | |
| procedure, public :: clear => vec_string_clear | |
| procedure, public :: destroy => vec_string_destroy | |
| procedure, public :: get_unchecked => vec_string_get_unchecked | |
| procedure, public :: is_empty => vec_string_is_empty | |
| procedure, public :: pop_back => vec_string_pop_back | |
| procedure, public :: push_back => vec_string_push_back | |
| procedure, public :: reserve => vec_string_reserve | |
| procedure, public :: resize => vec_string_resize | |
| procedure, public :: set => vec_string_set | |
| procedure, public :: shrink_to_fit => vec_string_shrink_to_fit | |
| procedure, public :: size => vec_string_size | |
| procedure, public :: take => vec_string_take |
A copy holding exactly size() elements.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_dp_t), | intent(in) | :: | self |
Elements that fit before the next reallocation.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_dp_t), | intent(in) | :: | 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_dp_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_dp_t), | intent(in) | :: | self |
Number of live elements.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_dp_t), | intent(in) | :: | self |
A copy holding exactly size() elements.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_int32_t), | intent(in) | :: | self |
Elements that fit before the next reallocation.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_int32_t), | intent(in) | :: | 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 |
Number of live elements.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_int32_t), | intent(in) | :: | self |
A copy holding exactly size() elements.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_int64_t), | intent(in) | :: | self |
Elements that fit before the next reallocation.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_int64_t), | intent(in) | :: | 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_int64_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_int64_t), | intent(in) | :: | self |
Number of live elements.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_int64_t), | intent(in) | :: | self |
A copy holding exactly size() elements.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_string_t), | intent(in) | :: | self |
Elements that fit before the next reallocation.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_string_t), | intent(in) | :: | 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 |
Number of live elements.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_string_t), | intent(in) | :: | self |
Append many elements, growing once rather than once per element.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_dp_t), | intent(inout) | :: | self | |||
| real(kind=dp), | intent(in) | :: | values(:) | |||
| type(error_t), | intent(inout), | optional | :: | err |
Read element index, 1-based. ERROR_BOUNDS when out of range.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_dp_t), | intent(in) | :: | self | |||
| integer(kind=default_int), | intent(in) | :: | index | |||
| real(kind=dp), | intent(out) | :: | value | |||
| type(error_t), | intent(inout), | optional | :: | err |
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_dp_t), | intent(inout) | :: | self |
Release all storage and reset to the empty state.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_dp_t), | intent(inout) | :: | self |
Ensure capacity for at least needed elements, preserving the live
ones. Capacity starts at PIC_VECTOR_MIN_CAPACITY and doubles, which
keeps a run of push_back calls amortised O(1).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_dp_t), | intent(inout) | :: | self | |||
| integer(kind=default_int), | intent(in) | :: | needed | |||
| type(error_t), | intent(inout), | optional | :: | err |
Remove and return the last element. ERROR_BOUNDS when empty, in
which case the vector is unchanged.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_dp_t), | intent(inout) | :: | self | |||
| real(kind=dp), | 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_dp_t), | intent(inout) | :: | self | |||
| real(kind=dp), | 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_dp_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_dp_t), | intent(inout) | :: | self | |||
| integer(kind=default_int), | intent(in) | :: | n | |||
| real(kind=dp), | 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_dp_t), | intent(inout) | :: | self | |||
| integer(kind=default_int), | intent(in) | :: | index | |||
| real(kind=dp), | intent(in) | :: | value | |||
| type(error_t), | intent(inout), | optional | :: | err |
Release capacity beyond size().
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_dp_t), | intent(inout) | :: | self | |||
| type(error_t), | intent(inout), | optional | :: | err |
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_dp_t), | intent(inout) | :: | self | |||
| real(kind=dp), | intent(out), | allocatable | :: | array(:) | ||
| type(error_t), | intent(inout), | optional | :: | err |
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 |
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 |
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 |
Ensure capacity for at least needed elements, preserving the live
ones. Capacity starts at PIC_VECTOR_MIN_CAPACITY and doubles, which
keeps a run of push_back calls amortised O(1).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_int32_t), | intent(inout) | :: | self | |||
| integer(kind=default_int), | intent(in) | :: | needed | |||
| type(error_t), | intent(inout), | optional | :: | err |
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 |
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 |
Append many elements, growing once rather than once per element.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_int64_t), | intent(inout) | :: | self | |||
| integer(kind=int64), | intent(in) | :: | values(:) | |||
| type(error_t), | intent(inout), | optional | :: | err |
Read element index, 1-based. ERROR_BOUNDS when out of range.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_int64_t), | intent(in) | :: | self | |||
| integer(kind=default_int), | intent(in) | :: | index | |||
| integer(kind=int64), | intent(out) | :: | value | |||
| type(error_t), | intent(inout), | optional | :: | err |
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_int64_t), | intent(inout) | :: | self |
Release all storage and reset to the empty state.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_int64_t), | intent(inout) | :: | self |
Ensure capacity for at least needed elements, preserving the live
ones. Capacity starts at PIC_VECTOR_MIN_CAPACITY and doubles, which
keeps a run of push_back calls amortised O(1).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_int64_t), | intent(inout) | :: | self | |||
| integer(kind=default_int), | intent(in) | :: | needed | |||
| type(error_t), | intent(inout), | optional | :: | err |
Remove and return the last element. ERROR_BOUNDS when empty, in
which case the vector is unchanged.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_int64_t), | intent(inout) | :: | self | |||
| integer(kind=int64), | 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_int64_t), | intent(inout) | :: | self | |||
| integer(kind=int64), | 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_int64_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_int64_t), | intent(inout) | :: | self | |||
| integer(kind=default_int), | intent(in) | :: | n | |||
| integer(kind=int64), | 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_int64_t), | intent(inout) | :: | self | |||
| integer(kind=default_int), | intent(in) | :: | index | |||
| integer(kind=int64), | intent(in) | :: | value | |||
| type(error_t), | intent(inout), | optional | :: | err |
Release capacity beyond size().
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_int64_t), | intent(inout) | :: | self | |||
| type(error_t), | intent(inout), | optional | :: | err |
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_int64_t), | intent(inout) | :: | self | |||
| integer(kind=int64), | intent(out), | allocatable | :: | array(:) | ||
| type(error_t), | intent(inout), | optional | :: | err |
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 |
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 |
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 |
Ensure capacity for at least needed elements, preserving the live
ones. Capacity starts at PIC_VECTOR_MIN_CAPACITY and doubles, which
keeps a run of push_back calls amortised O(1).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vector_string_t), | intent(inout) | :: | self | |||
| integer(kind=default_int), | intent(in) | :: | needed | |||
| type(error_t), | intent(inout), | optional | :: | err |
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 |
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 |