Grow the colors' storage to hold at least n.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(Trajectory), | intent(inout) | :: | self | |||
| integer, | intent(in) | :: | n |
colors to hold |
||
| logical, | intent(in), | optional | :: | exact |
(true: exactly n (default false)) |
subroutine grow_colors(self, n, exact) type(Trajectory), intent(inout) :: self integer, intent(in) :: n !! colors to hold logical, intent(in), optional :: exact !! (true: exactly n (default false)) real(c_float), allocatable :: tmp(:,:) integer :: cap cap = 0 if (allocated(self%col)) cap = size(self%col, 2) if (n <= cap) return allocate(tmp(4, new_capacity(cap, n, exact))) if (self%n_col > 0) tmp(:, 1:self%n_col) = self%col(:, 1:self%n_col) call move_alloc(tmp, self%col) end subroutine grow_colors