iDynamicArray Derived Type

type, public :: iDynamicArray

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



Components

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

Current size of the array

integer(kind=i32), 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 iDynamicArray

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

    Overloaded by interface iDynamicArray()

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

    Return type.

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

    Overloaded by interface iDynamicArray()

    Arguments

    Type IntentOptional AttributesName
    integer(kind=i32), 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(iDynamicArray)

    Return type


Type-Bound Procedures

procedure, public :: append => append_iDynamicArray

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

  • private subroutine append_iDynamicArray(this, val)

    Overloaded type bound procedure iDynamicArray%append()

    Arguments

    Type IntentOptional AttributesName
    class(iDynamicArray) :: this
    integer(kind=i32) :: val

    Value to append.

procedure, public :: deallocate => deallocate_iDynamicArray

iDynamicArray%deallocate() - Deallocate a dynamic array.

  • private subroutine deallocate_iDynamicArray(this)

    Overloaded type bound procedure iDynamicArray%deallocate()

    Arguments

    Type IntentOptional AttributesName
    class(iDynamicArray) :: this

procedure, public :: insertAt => insertAt_iDynamicArray

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

  • private subroutine insertAt_iDynamicArray(this, i, val)

    Private insert into array without checking for sorted flag.

    Arguments

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

    Insert value at this location.

    integer(kind=i32) :: val

    Insert this value.

procedure, public :: insertSorted => insertSorted_iDynamicArray

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

  • private subroutine insertSorted_iDynamicArray(this, val)

    Overloaded type bound procedure iDynamicArray%insertSorted()

    Arguments

    Type IntentOptional AttributesName
    class(iDynamicArray) :: this
    integer(kind=i32) :: val

    Insert this value.

procedure, public :: insertSortedUnique => insertSortedUnique_iDynamicArray

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

  • private subroutine insertSortedUnique_iDynamicArray(this, val)

    Overloaded type bound procedure iDynamicArray%insertSortedUnique()

    Arguments

    Type IntentOptional AttributesName
    class(iDynamicArray) :: this
    integer(kind=i32) :: val

    Insert this value.

procedure, public :: isEmpty => isEmpty_iDynamicArray

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

  • private function isEmpty_iDynamicArray(this) result(yes)

    Overloaded type bound procedure iDynamicArray%isEmpty()

    Arguments

    Type IntentOptional AttributesName
    class(iDynamicArray) :: this

    Return Value logical

    Array is empty

procedure, public :: isFilled => isFilled_iDynamicArray

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

  • private function isFilled_iDynamicArray(this) result(yes)

    Overloaded type bound procedure iDynamicArray%isFilled()

    Arguments

    Type IntentOptional AttributesName
    class(iDynamicArray) :: this

    Return Value logical

    Array is filled

procedure, public :: locationOf => locationOf_iDynamicArray

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

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

    Overloaded type bound procedure iDynamicArray%locationOf().

    Arguments

    Type IntentOptional AttributesName
    class(iDynamicArray) :: this
    integer(kind=i32) :: val

    Get the location of this value

    Return Value integer(kind=i32)

    Location of value

procedure, public :: prepend => prepend_iDynamicArray

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

  • private subroutine prepend_iDynamicArray(this, val)

    Overloaded type bound procedure iDynamicArray%prepend()

    Arguments

    Type IntentOptional AttributesName
    class(iDynamicArray) :: this
    integer(kind=i32) :: val

    Value to prepend.

procedure, public :: reallocate => reallocate_iDynamicArray

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

  • private subroutine reallocate_iDynamicArray(this, M)

    Overloaded type bound procedure iDynamicArray%reallocate().

    Arguments

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

    Reallocate memory to this size.

procedure, public :: remove => remove_iDynamicArray

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

  • private subroutine remove_iDynamicArray(this, i)

    Overloaded type bound procedure iDynamicArray%remove().

    Arguments

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

    Remove the value at this location.

procedure, public :: tighten => tighten_iDynamicArray

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

  • private subroutine tighten_iDynamicArray(this)

    Overloaded type bound procedure iDynamicArray%tighten().

    Arguments

    Type IntentOptional AttributesName
    class(iDynamicArray) :: this