new_capacity Function

private pure function new_capacity(current, needed, exact)

The capacity to grow to for needed points: twice the current, or what is needed and a quarter more (so that appending after a large bulk add doesn't copy everything at once); exact (reserve): what is needed.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: current

current capacity

integer, intent(in) :: needed

points needed

logical, intent(in), optional :: exact

(true: what is needed (default false))

Return Value integer


Called by

proc~~new_capacity~~CalledByGraph proc~new_capacity new_capacity proc~grow_attitudes grow_attitudes proc~grow_attitudes->proc~new_capacity proc~grow_colors grow_colors proc~grow_colors->proc~new_capacity proc~grow_positions grow_positions proc~grow_positions->proc~new_capacity proc~grow_times grow_times proc~grow_times->proc~new_capacity proc~add_attitude Trajectory%add_attitude proc~add_attitude->proc~grow_attitudes proc~add_color Trajectory%add_color proc~add_color->proc~grow_colors proc~add_points Trajectory%add_points proc~add_points->proc~grow_attitudes proc~add_points->proc~grow_colors proc~add_points->proc~grow_positions proc~add_points->proc~grow_times proc~add_position Trajectory%add_position proc~add_position->proc~grow_positions proc~add_time Trajectory%add_time proc~add_time->proc~grow_times proc~reserve~2 Trajectory%reserve proc~reserve~2->proc~grow_attitudes proc~reserve~2->proc~grow_colors proc~reserve~2->proc~grow_positions proc~reserve~2->proc~grow_times proc~add_point Trajectory%add_point proc~add_point->proc~add_attitude proc~add_point->proc~add_color proc~add_point->proc~add_position proc~add_point->proc~add_time

Source Code

    pure integer function new_capacity(current, needed, exact)
        integer, intent(in) :: current                  !! current capacity
        integer, intent(in) :: needed                   !! points needed
        logical, intent(in), optional :: exact          !! (true: what is needed (default false))
        new_capacity = max(needed + needed / 4, 2 * current, 16)
        if (present(exact)) then
            if (exact) new_capacity = needed
        end if
    end function new_capacity