rDynamicArray Derived Type

type, public :: rDynamicArray

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



Components

TypeVisibility AttributesNameInitial
integer(kind=i32), public :: N

Current size of the array

real(kind=r32), public, allocatable:: values(:)

Memory for values, can be larger than N

logical, public :: sorted =.false.

Keep track of whether the array is sorted for potential speed increases

logical, public :: fixed =.false.

Don't allow the memory to change after initial instantiation.


Constructor

public interface rDynamicArray

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

    Overloaded by interface rDynamicArray()

    Arguments

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

    Amount of memory to allocate.

    logical, intent(in), optional :: sorted

    Maintain a sorted array.

    logical, intent(in), optional :: fixed

    Maintain a fixed size array.

    Return Value type(rDynamicArray)

    Return type.

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

    Overloaded by interface rDynamicArray()

    Arguments

    Type IntentOptional AttributesName
    real(kind=r32), intent(in) :: values(:)

    Set of values to initialize with.

    integer(kind=i32), intent(in), optional :: M

    Amount of memory to allocate.

    logical, intent(in), optional :: sorted

    Maintain a sorted array.

    logical, intent(in), optional :: fixed

    Maintain a fixed size array.

    Return Value type(rDynamicArray)

    Return type


Type-Bound Procedures

procedure, public :: append => append_rDynamicArray

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

  • private subroutine append_rDynamicArray(this, val)

    Overloaded type bound procedure rDynamicArray%append()

    Arguments

    Type IntentOptional AttributesName
    class(rDynamicArray) :: this
    real(kind=r32) :: val

    Value to append.

procedure, public :: deallocate => deallocate_rDynamicArray

rDynamicArray%deallocate() - Deallocate a dynamic array.

  • private subroutine deallocate_rDynamicArray(this)

    Overloaded type bound procedure rDynamicArray%deallocate()

    Arguments

    Type IntentOptional AttributesName
    class(rDynamicArray) :: this

procedure, public :: insertAt => insertAt_rDynamicArray

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

  • private subroutine insertAt_rDynamicArray(this, i, val)

    Private insert into array without checking for sorted flag.

    Arguments

    Type IntentOptional AttributesName
    class(rDynamicArray) :: this
    integer(kind=i32) :: i

    Insert value at this location.

    real(kind=r32) :: val

    Insert this value.

procedure, public :: insertSorted => insertSorted_rDynamicArray

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

  • private subroutine insertSorted_rDynamicArray(this, val)

    Overloaded type bound procedure rDynamicArray%insertSorted()

    Arguments

    Type IntentOptional AttributesName
    class(rDynamicArray) :: this
    real(kind=r32) :: val

    Insert this value.

procedure, public :: insertSortedUnique => insertSortedUnique_rDynamicArray

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

  • private subroutine insertSortedUnique_rDynamicArray(this, val)

    Overloaded type bound procedure rDynamicArray%insertSortedUnique()

    Arguments

    Type IntentOptional AttributesName
    class(rDynamicArray) :: this
    real(kind=r32) :: val

    Insert this value.

procedure, public :: isEmpty => isEmpty_rDynamicArray

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

  • private function isEmpty_rDynamicArray(this) result(yes)

    Overloaded type bound procedure rDynamicArray%isEmpty()

    Arguments

    Type IntentOptional AttributesName
    class(rDynamicArray) :: this

    Return Value logical

    Array is empty

procedure, public :: isFilled => isFilled_rDynamicArray

rDynamicArray%isFilled() - True if the array is filled.

  • private function isFilled_rDynamicArray(this) result(yes)

    Overloaded type bound procedure rDynamicArray%isFilled()

    Arguments

    Type IntentOptional AttributesName
    class(rDynamicArray) :: this

    Return Value logical

    Array is filled

procedure, public :: locationOf => locationOf_rDynamicArray

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

  • private function locationOf_rDynamicArray(this, val) result(i)

    Overloaded type bound procedure rDynamicArray%locationOf().

    Arguments

    Type IntentOptional AttributesName
    class(rDynamicArray) :: this
    real(kind=r32) :: val

    Get the location of this value

    Return Value integer(kind=i32)

    Location of value

procedure, public :: prepend => prepend_rDynamicArray

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

  • private subroutine prepend_rDynamicArray(this, val)

    Overloaded type bound procedure rDynamicArray%prepend()

    Arguments

    Type IntentOptional AttributesName
    class(rDynamicArray) :: this
    real(kind=r32) :: val

    Value to prepend.

procedure, public :: reallocate => reallocate_rDynamicArray

rDynamicArray%reallocate() - Create new contiguous memory to match the needs of the expanding or shrinking array.

  • private subroutine reallocate_rDynamicArray(this, M)

    Overloaded type bound procedure rDynamicArray%reallocate().

    Arguments

    Type IntentOptional AttributesName
    class(rDynamicArray) :: this
    integer(kind=i32) :: M

    Reallocate memory to this size.

procedure, public :: remove => remove_rDynamicArray

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

  • private subroutine remove_rDynamicArray(this, i)

    Overloaded type bound procedure rDynamicArray%remove().

    Arguments

    Type IntentOptional AttributesName
    class(rDynamicArray) :: this
    integer(kind=i32) :: i

    Remove the value at this location.

procedure, public :: tighten => tighten_rDynamicArray

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

  • private subroutine tighten_rDynamicArray(this)

    Overloaded type bound procedure rDynamicArray%tighten().

    Arguments

    Type IntentOptional AttributesName
    class(rDynamicArray) :: this