dDynamicArray Derived Type

type, public :: dDynamicArray

Class that act as stacks, queues, and priority queues. See dDynamicArray_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=r64), 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 dDynamicArray

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

    Overloaded by interface dDynamicArray()

    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(dDynamicArray)

    Return type.

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

    Overloaded by interface dDynamicArray()

    Arguments

    Type IntentOptional AttributesName
    real(kind=r64), 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(dDynamicArray)

    Return type


Type-Bound Procedures

procedure, public :: append => append_dDynamicArray

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

  • private subroutine append_dDynamicArray(this, val)

    Overloaded type bound procedure dDynamicArray%append()

    Arguments

    Type IntentOptional AttributesName
    class(dDynamicArray) :: this
    real(kind=r64) :: val

    Value to append.

procedure, public :: deallocate => deallocate_dDynamicArray

dDynamicArray%deallocate() - Deallocate a dynamic array.

  • private subroutine deallocate_dDynamicArray(this)

    Overloaded type bound procedure dDynamicArray%deallocate()

    Arguments

    Type IntentOptional AttributesName
    class(dDynamicArray) :: this

procedure, public :: insertAt => insertAt_dDynamicArray

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

  • private subroutine insertAt_dDynamicArray(this, i, val)

    Overloaded type bound procedure dDynamicArray%insertAt()

    Arguments

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

    Insert value at this location.

    real(kind=r64) :: val

    Insert this value.

procedure, public :: insertSorted => insertSorted_dDynamicArray

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

  • private subroutine insertSorted_dDynamicArray(this, val)

    Overloaded type bound procedure dDynamicArray%insertSorted()

    Arguments

    Type IntentOptional AttributesName
    class(dDynamicArray) :: this
    real(kind=r64) :: val

    Insert this value.

procedure, public :: insertSortedUnique => insertSortedUnique_dDynamicArray

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

  • private subroutine insertSortedUnique_dDynamicArray(this, val)

    Overloaded type bound procedure dDynamicArray%insertSortedUnique()

    Arguments

    Type IntentOptional AttributesName
    class(dDynamicArray) :: this
    real(kind=r64) :: val

    Insert this value.

procedure, public :: isEmpty => isEmpty_dDynamicArray

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

  • private function isEmpty_dDynamicArray(this) result(yes)

    Overloaded type bound procedure dDynamicArray%isEmpty()

    Arguments

    Type IntentOptional AttributesName
    class(dDynamicArray) :: this

    Return Value logical

    Array is empty

procedure, public :: isFilled => isFilled_dDynamicArray

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

  • private function isFilled_dDynamicArray(this) result(yes)

    Overloaded type bound procedure dDynamicArray%isFilled()

    Arguments

    Type IntentOptional AttributesName
    class(dDynamicArray) :: this

    Return Value logical

    Array is filled

procedure, public :: locationOf => locationOf_dDynamicArray

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

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

    Overloaded type bound procedure dDynamicArray%locationOf().

    Arguments

    Type IntentOptional AttributesName
    class(dDynamicArray) :: this
    real(kind=r64) :: val

    Get the location of this value

    Return Value integer(kind=i32)

    Location of value

procedure, public :: prepend => prepend_dDynamicArray

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

  • private subroutine prepend_dDynamicArray(this, val)

    Overloaded type bound procedure dDynamicArray%prepend()

    Arguments

    Type IntentOptional AttributesName
    class(dDynamicArray) :: this
    real(kind=r64) :: val

    Value to prepend.

procedure, public :: reallocate => reallocate_dDynamicArray

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

  • private subroutine reallocate_dDynamicArray(this, M)

    Overloaded type bound procedure dDynamicArray%reallocate().

    Arguments

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

    Reallocate memory to this size.

procedure, public :: remove => remove_dDynamicArray

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

  • private subroutine remove_dDynamicArray(this, i)

    Overloaded type bound procedure dDynamicArray%remove().

    Arguments

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

    Remove the value at this location.

procedure, public :: tighten => tighten_dDynamicArray

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

  • private subroutine tighten_dDynamicArray(this)

    Overloaded type bound procedure dDynamicArray%tighten().

    Arguments

    Type IntentOptional AttributesName
    class(dDynamicArray) :: this