Bounded array of real(dp) with fixed inline storage.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=dp), | private | :: | items(PIC_FIXED_ARRAY_CAPACITY) |
Inline storage. Deliberately not |
|||
| integer(kind=default_int), | private | :: | n_items | = | 0 |
Number of live elements, always in |
Copy of the live elements as a plain array of extent size(),
not capacity(). Returns a zero-length array when empty. This is
how the contents are handed to ordinary Fortran routines; note
that it is the one operation here that does allocate, so keep it
out of the hot path.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(fixed_array_dp_t), | intent(in) | :: | self |
Bounds-checked element access, 1-based. Any index outside
1:size() (including indices that are within the capacity but
beyond the live elements) sets value to zero and err to
ERROR_VALIDATION. On success err is left untouched.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(fixed_array_dp_t), | intent(in) | :: | self | |||
| integer(kind=default_int), | intent(in) | :: | index | |||
| real(kind=dp), | intent(out) | :: | value | |||
| type(error_t), | intent(inout) | :: | err |
Maximum number of elements, i.e. PIC_FIXED_ARRAY_CAPACITY.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(fixed_array_dp_t), | intent(in) | :: | self |
Drop every element. The storage itself is untouched, so this is a single integer assignment; the array can be reused immediately.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(fixed_array_dp_t), | intent(inout) | :: | self |
UNCHECKED element access for inner loops: no bounds check at all.
The caller is responsible for guaranteeing 1 <= index <= size(),
typically by looping over 1, array%size(). Reading an index
outside that range returns undefined data. Use at unless the
bounds check is measurably in the way.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(fixed_array_dp_t), | intent(in) | :: | self | |||
| integer(kind=default_int), | intent(in) | :: | index |
True when no elements are live.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(fixed_array_dp_t), | intent(in) | :: | self |
True when a further push_back would fail.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(fixed_array_dp_t), | intent(in) | :: | self |
Remove and return the last element (LIFO). On an empty array
value is set to zero and err is set to ERROR_VALIDATION.
On success err is left untouched.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(fixed_array_dp_t), | intent(inout) | :: | self | |||
| real(kind=dp), | intent(out) | :: | value | |||
| type(error_t), | intent(inout) | :: | err |
Append an element. If the array is already at capacity the element
is not stored, the size is left unchanged and err is set to
ERROR_VALIDATION. On success err is left untouched.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(fixed_array_dp_t), | intent(inout) | :: | self | |||
| real(kind=dp), | intent(in) | :: | value | |||
| type(error_t), | intent(inout) | :: | err |
Number of live elements.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(fixed_array_dp_t), | intent(in) | :: | self |
type :: fixed_array_dp_t !! Bounded array of `real(dp)` with fixed inline storage. integer(default_int), private :: n_items = 0 !! Number of live elements, always in `0:PIC_FIXED_ARRAY_CAPACITY` real(dp), private :: items(PIC_FIXED_ARRAY_CAPACITY) !! Inline storage. Deliberately not `allocatable`: no heap, ever. !! Elements above `n_items` are undefined and must not be read. contains procedure :: push_back => fixed_array_dp_push_back procedure :: pop_back => fixed_array_dp_pop_back procedure :: at => fixed_array_dp_at procedure :: get_unchecked => fixed_array_dp_get_unchecked procedure :: size => fixed_array_dp_size procedure :: capacity => fixed_array_dp_capacity procedure :: is_empty => fixed_array_dp_is_empty procedure :: is_full => fixed_array_dp_is_full procedure :: clear => fixed_array_dp_clear procedure :: as_array => fixed_array_dp_as_array end type fixed_array_dp_t