Simple amortized string accumulator.
Used to build arrays of strings efficiently without repeated reallocation.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| type(string_t), | public, | allocatable | :: | a(:) | |||
| integer, | public | :: | n | = | 0 |
Append a string to the accumulator (grows capacity as needed).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(string_accum_t), | intent(inout) | :: | self | |||
| character(len=*), | intent(in) | :: | s |
Materialize the accumulator into a right-sized array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(string_accum_t), | intent(inout) | :: | self | |||
| type(string_t), | intent(out), | allocatable | :: | out(:) |
type string_accum_t type(string_t), allocatable :: a(:) integer :: n = 0 contains procedure :: push => accum_push procedure :: to_array => accum_to_array end type string_accum_t