dynamical_list_t Derived Type

type, public :: dynamical_list_t

List of integers with a given maximum fixed size The first index is always 1, and filled up to n_used It contains routines for managing the list


Inherited by

type~~dynamical_list_t~~InheritedByGraph type~dynamical_list_t dynamical_list_t type~weighted_sampler_t~2 weighted_sampler_t type~weighted_sampler_t~2->type~dynamical_list_t indices type~weighted_sampler_t~3 weighted_sampler_t type~weighted_sampler_t~3->type~dynamical_list_t indices type~weighted_sampler_t~4 weighted_sampler_t type~weighted_sampler_t~4->type~weighted_sampler_t~2 samplers type~weighted_sampler_t~5 weighted_sampler_t type~weighted_sampler_t~5->type~weighted_sampler_t~3 samplers type~weighted_sampler_t~6 weighted_sampler_t type~weighted_sampler_t~6->type~weighted_sampler_t~2 samplers

Components

Type Visibility Attributes Name Initial
integer(kind=i4), public :: n = 0
integer(kind=i4), public :: n_used = 0
integer(kind=i4), public, allocatable :: list(:)

Finalization Procedures

final :: finalize_dynamical_list

  • private subroutine finalize_dynamical_list(this)

    Finalize the list For that, we need to deallocate the list

    Arguments

    Type IntentOptional Attributes Name
    type(dynamical_list_t), intent(inout) :: this

Type-Bound Procedures

procedure, public :: init => dynamical_list_init

  • private subroutine dynamical_list_init(this, n)

    Initialize an empty list with a given size Input: n - the size of the list

    Arguments

    Type IntentOptional Attributes Name
    class(dynamical_list_t), intent(inout) :: this
    integer(kind=i4), intent(in) :: n

procedure, public :: reset => dynamical_list_reset

  • private subroutine dynamical_list_reset(this)

    Reset the list For that, we only need to set n_used to 0

    Arguments

    Type IntentOptional Attributes Name
    class(dynamical_list_t), intent(inout) :: this

procedure, public :: print => dynamical_list_print

  • private subroutine dynamical_list_print(this)

    Print the list

    Arguments

    Type IntentOptional Attributes Name
    class(dynamical_list_t), intent(in) :: this

procedure, public :: expand => dynamical_list_expand

  • private subroutine dynamical_list_expand(this, new_size)

    Expand the list to a new size

    Arguments

    Type IntentOptional Attributes Name
    class(dynamical_list_t), intent(inout) :: this
    integer(kind=i4), intent(in) :: new_size

procedure, public :: trim => dynamical_list_trim

  • private subroutine dynamical_list_trim(this)

    Trim the list to the number of used elements

    Arguments

    Type IntentOptional Attributes Name
    class(dynamical_list_t), intent(inout) :: this

procedure, public :: last => dynamical_list_last

  • private function dynamical_list_last(this) result(val)

    Returns the last element of the list

    Arguments

    Type IntentOptional Attributes Name
    class(dynamical_list_t), intent(in) :: this

    Return Value integer(kind=i4)

procedure, public :: count => dynamical_list_count

  • private function dynamical_list_count(this, element) result(cnt)

    Count the number of times an element appears in the list

    Arguments

    Type IntentOptional Attributes Name
    class(dynamical_list_t), intent(in) :: this
    integer(kind=i4), intent(in) :: element

    Return Value integer(kind=i4)

generic, public :: add => dynamical_list_add_element, dynamical_list_add_array

  • private subroutine dynamical_list_add_element(this, element)

    Add an element to the list It assumes that the list is already allocated The element is added to the end of the list Input: element - the element to add

    Arguments

    Type IntentOptional Attributes Name
    class(dynamical_list_t), intent(inout) :: this
    integer(kind=i4), intent(in) :: element
  • private subroutine dynamical_list_add_array(this, array)

    Add an array to the list It will initialize the list if it is not already allocated, with the size of the array Input: array - the array to add

    Arguments

    Type IntentOptional Attributes Name
    class(dynamical_list_t), intent(inout) :: this
    integer(kind=i4), intent(in) :: array(:)

generic, public :: remove => dynamical_list_remove_position, dynamical_list_remove_position_array, dynamical_list_remove_position_range

  • private subroutine dynamical_list_remove_position(this, position)

    Remove an element from the list It will replace the element at the given position with the last element WARNING: This can change the position of the elements in the list, DO NOT use sequentially with the original indexes, that are not updated after each removal Input: position - the position of the element to remove

    Arguments

    Type IntentOptional Attributes Name
    class(dynamical_list_t), intent(inout) :: this
    integer(kind=i4), intent(in) :: position
  • private subroutine dynamical_list_remove_position_array(this, position_arr)

    Remove a list of elements from the list It will replace the elements in the list with the last elements For that, we need to sort the positions It is safe because the elements are removed in reverse order Input: position_arr - the array of positions to remove Dependency: stdlib_sorting

    Arguments

    Type IntentOptional Attributes Name
    class(dynamical_list_t), intent(inout) :: this
    integer(kind=i4), intent(in) :: position_arr(:)
  • private subroutine dynamical_list_remove_position_range(this, ini_position, fin_position)

    Remove a range of elements from the list It will replace the elements in the range with the last elements This is safe because the elements are removed in reverse order Input: ini_position - the initial position of the range to remove fin_position - the final position of the range to remove

    Arguments

    Type IntentOptional Attributes Name
    class(dynamical_list_t), intent(inout) :: this
    integer(kind=i4), intent(in) :: ini_position
    integer(kind=i4), intent(in) :: fin_position

generic, public :: assignment(=) => dynamical_list_create_from_array

  • private subroutine dynamical_list_create_from_array(this, array)

    Create from array, if it is not already allocated Input: array - the array to create the list from

    Arguments

    Type IntentOptional Attributes Name
    class(dynamical_list_t), intent(inout) :: this
    integer(kind=i4), intent(in) :: array(:)

procedure, public :: get => dynamical_list_get

  • private function dynamical_list_get(this, position) result(val)

    Returns the element at the given position Input: position - the position of the element to return

    Arguments

    Type IntentOptional Attributes Name
    class(dynamical_list_t), intent(in) :: this
    integer(kind=i4), intent(in) :: position

    Return Value integer(kind=i4)

procedure, public :: sum => dynamical_list_sum

  • private function dynamical_list_sum(this) result(val)

    Return the sum of the elements in the list It sums only the valid elements

    Arguments

    Type IntentOptional Attributes Name
    class(dynamical_list_t), intent(in) :: this

    Return Value integer(kind=i4)