string_accum_t Derived Type

type, public :: string_accum_t

Simple amortized string accumulator.

Used to build arrays of strings efficiently without repeated reallocation.


Inherits

type~~string_accum_t~~InheritsGraph type~string_accum_t string_accum_t string_t string_t type~string_accum_t->string_t a

Components

Type Visibility Attributes Name Initial
type(string_t), public, allocatable :: a(:)
integer, public :: n = 0

Type-Bound Procedures

procedure, public :: push => accum_push

  • private subroutine accum_push(self, s)

    Append a string to the accumulator (grows capacity as needed).

    Arguments

    Type IntentOptional Attributes Name
    class(string_accum_t), intent(inout) :: self
    character(len=*), intent(in) :: s

procedure, public :: to_array => accum_to_array

  • private subroutine accum_to_array(self, out)

    Materialize the accumulator into a right-sized array.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(string_accum_t), intent(inout) :: self
    type(string_t), intent(out), allocatable :: out(:)

Source Code

   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