rArgDynamicArray_Class Module

module~~rargdynamicarray_class~~UsesGraph module~rargdynamicarray_class rArgDynamicArray_Class module~idynamicarray_class iDynamicArray_Class module~idynamicarray_class->module~rargdynamicarray_class module~variablekind variableKind module~variablekind->module~rargdynamicarray_class module~variablekind->module~idynamicarray_class module~m_strings m_strings module~variablekind->module~m_strings module~m_errors m_errors module~variablekind->module~m_errors module~m_searching m_searching module~variablekind->module~m_searching module~rdynamicarray_class rDynamicArray_Class module~variablekind->module~rdynamicarray_class module~m_sort m_sort module~variablekind->module~m_sort module~m_allocate m_allocate module~variablekind->module~m_allocate module~m_deallocate m_deallocate module~variablekind->module~m_deallocate module~m_reallocate m_reallocate module~variablekind->module~m_reallocate module~m_unittester m_unitTester module~variablekind->module~m_unittester module~m_parameters m_parameters module~variablekind->module~m_parameters module~m_strings->module~rargdynamicarray_class module~m_strings->module~idynamicarray_class module~m_strings->module~rdynamicarray_class module~m_errors->module~rargdynamicarray_class module~m_errors->module~idynamicarray_class module~m_errors->module~m_strings module~m_errors->module~rdynamicarray_class module~m_errors->module~m_allocate module~m_errors->module~m_deallocate module~m_errors->module~m_reallocate module~m_errors->module~m_unittester module~m_searching->module~rargdynamicarray_class module~m_searching->module~idynamicarray_class module~m_searching->module~rdynamicarray_class module~rdynamicarray_class->module~rargdynamicarray_class module~m_sort->module~idynamicarray_class module~m_sort->module~rdynamicarray_class module~m_allocate->module~idynamicarray_class module~m_allocate->module~rdynamicarray_class module~m_allocate->module~m_reallocate module~m_deallocate->module~idynamicarray_class module~m_deallocate->module~rdynamicarray_class module~m_reallocate->module~idynamicarray_class module~m_reallocate->module~rdynamicarray_class module~m_unittester->module~m_allocate iso_fortran_env iso_fortran_env iso_fortran_env->module~variablekind iso_fortran_env->module~m_strings iso_fortran_env->module~m_errors iso_fortran_env->module~m_unittester module~m_parameters->module~m_strings
Help

Class that act as stacks, queues, and priority queues like rDynamicArray_Class but with an added integer index so that 'lists' of both a key and value can be maintained. These classes use dynamically allocated contiguous blocks of memory to store a list of numbers. The queues can be sorted to become priority queues and use binary searches to quickly insert new numbers. If the allocated memory is filled, the available space is doubled. Memory is only reallocated to a smaller size, if the utilization is a quarter of that allocated. The array can be specified as fixed, so that no reallocation occurs. This is useful for heaps of given like k nearest neighbours, or k smallest.

Example usage

program dynamicArray_test
use variableKind, only: i32
use m_iArgDynamicArray, only: iArgDynamicArray

implicit none

type(rArgDynamicArray) :: da, da2
integer(i32) :: ia

da = rArgDynamicArray(10)
call da%insertAt(1, 10, 10.0)
call da%insertAt(1, 20, 20.0)
call da%prepend(30, 30.0)
call da%append(40, 40.0)
call da%remove(2)
call da%tighten()
da2 = da
da2%v%values(2) = 50.0
call da%deallocate()
call da2%deallocate()

da = rArgDynamicArray(3, sorted=.true.)
call da%insertSorted(1, 20.0)
call da%insertSorted(2, 30.0)
call da%insertSorted(3, 10.0)
ia = da%locationOf(20.0)
ia = da%argOf(20.0)
call da%insertSortedUnique(4, 10.0)
call da%insertSortedUnique(4, 15.0)
call da%deallocate()

da = rArgDynamicArray(3, sorted=.true., fixed=.true.)
call da%insertSorted(1, 20.0)
call da%insertSorted(2, 30.0)
call da%insertSorted(3, 10.0)
ia = da%locationOf(20.0)
ia = da%argOf(20.0)
call da%insertSortedUnique(4, 10.0)
call da%insertSortedUnique(4, 15.0)
call da%deallocate()
end program

Used By

module~~rargdynamicarray_class~~UsedByGraph module~rargdynamicarray_class rArgDynamicArray_Class module~m_tests m_tests module~rargdynamicarray_class->module~m_tests program~test_coretran test_coretran module~m_tests->program~test_coretran
Help


Interfaces

public interface rArgDynamicArray

  • private function init_rArgDynamicArray_i1(M, sorted, fixed) result(this)

    Overloaded by interface [[rArgDynamicArray(type)]]

    Arguments

    Type IntentOptional AttributesName
    integer(kind=i32), intent(in), optional :: M
    logical, intent(in), optional :: sorted
    logical, intent(in), optional :: fixed

    Return Value type(rArgDynamicArray)

  • private function init_rArgDynamicArray_r1D(i, values, M, sorted, fixed) result(this)

    Overloaded by interface [[rArgDynamicArray(type)]]

    Arguments

    Type IntentOptional AttributesName
    integer(kind=i32), intent(in) :: i(:)
    real(kind=r32), intent(in) :: values(:)
    integer(kind=i32), intent(in), optional :: M
    logical, intent(in), optional :: sorted
    logical, intent(in), optional :: fixed

    Return Value type(rArgDynamicArray)


Derived Types

type, public :: rArgDynamicArray

Class that act as stacks, queues, and priority queues. See rArgDynamicArray_Class for more information on how to use this class.

Components

TypeVisibility AttributesNameInitial
type(iDynamicArray), public :: i

Argument of the values.

type(rDynamicArray), public :: v

Values.

Constructor

private function init_rArgDynamicArray_i1(M, sorted, fixed)

Overloaded by interface [[rArgDynamicArray(type)]]

private function init_rArgDynamicArray_r1D(i, values, M, sorted, fixed)

Overloaded by interface [[rArgDynamicArray(type)]]

Type-Bound Procedures

procedure, public :: append => append_rArgDynamicArray

rArgDynamicArray%append() - Append a value to the end of the dynamic array. Will change a sorted dynamic array to unsorted.

procedure, public :: argOf => argOf_rArgDynamicArray

rArgDynamicArray%argOf() - Get the argument of a value in a sorted dynamic array

procedure, public :: deallocate => deallocate_rArgDynamicArray

rArgDynamicArray%%deallocate() - Deallocate a dynamic array.

procedure, public :: insertAt => insertAt_rArgDynamicArray

rArgDynamicArray%insertAt() - Insert a value at a given index.

procedure, public :: insertSorted => insertSorted_rArgDynamicArray

rArgDynamicArray%insertSorted() - Insert a value into a sorted dynamic array.

procedure, public :: insertSortedUnique => insertSortedUnique_rArgDynamicArray

rArgDynamicArray%insertSortedUnique() - Inserts only unique numbers into a dynamic array.

procedure, public :: isEmpty => isEmpty_rArgDynamicArray

rArgDynamicArray%isEmpty() - True if the array is empty.

procedure, public :: isFilled => isFilled_rArgDynamicArray

rArgDynamicArray%isFilled() - True if the allocated memory has been filled.

procedure, public :: locationOf => locationOf_rArgDynamicArray

rArgDynamicArray%locationOf() - Get the location of a value in a sorted dynamic array.

procedure, public :: prepend => prepend_rArgDynamicArray

rArgDynamicArray%prepend() - Prepend a value to the start of the dynamic array. Only for unsorted dynamic arrays

procedure, public :: remove => remove_rArgDynamicArray

rArgDynamicArray%remove() - Remove an element from the array.

procedure, public :: tighten => tighten_rArgDynamicArray

rArgDynamicArray%tighten() - Removes excess buffer memory and trims it to the current length.