idDynamicArray Derived Type

type, public :: idDynamicArray

Class that act as stacks, queues, and priority queues. See idDynamicArray_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=i64), 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 idDynamicArray

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

    Overloaded by interface idDynamicArray()

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

    Return type.

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

    Overloaded by interface idDynamicArray()

    Arguments

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

    Return type


Type-Bound Procedures

procedure, public :: append => append_idDynamicArray

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

  • private subroutine append_idDynamicArray(this, val)

    Overloaded type bound procedure idDynamicArray%append()

    Arguments

    Type IntentOptional AttributesName
    class(idDynamicArray) :: this
    integer(kind=i64) :: val

    Value to append.

procedure, public :: deallocate => deallocate_idDynamicArray

idDynamicArray%deallocate() - Deallocate a dynamic array.

  • private subroutine deallocate_idDynamicArray(this)

    Overloaded type bound procedure idDynamicArray%deallocate()

    Arguments

    Type IntentOptional AttributesName
    class(idDynamicArray) :: this

procedure, public :: insertAt => insertAt_idDynamicArray

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

  • private subroutine insertAt_idDynamicArray(this, i, val)

    Private insert into array without checking for sorted flag.

    Arguments

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

    Insert value at this location.

    integer(kind=i64) :: val

    Insert this value.

procedure, public :: insertSorted => insertSorted_idDynamicArray

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

  • private subroutine insertSorted_idDynamicArray(this, val)

    Overloaded type bound procedure idDynamicArray%insertSorted()

    Arguments

    Type IntentOptional AttributesName
    class(idDynamicArray) :: this
    integer(kind=i64) :: val

    Insert this value.

procedure, public :: insertSortedUnique => insertSortedUnique_idDynamicArray

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

  • private subroutine insertSortedUnique_idDynamicArray(this, val)

    Overloaded type bound procedure idDynamicArray%insertSortedUnique()

    Arguments

    Type IntentOptional AttributesName
    class(idDynamicArray) :: this
    integer(kind=i64) :: val

    Insert this value.

procedure, public :: isEmpty => isEmpty_idDynamicArray

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

  • private function isEmpty_idDynamicArray(this) result(yes)

    Overloaded type bound procedure idDynamicArray%isEmpty()

    Arguments

    Type IntentOptional AttributesName
    class(idDynamicArray) :: this

    Return Value logical

    Array is empty

procedure, public :: isFilled => isFilled_idDynamicArray

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

  • private function isFilled_idDynamicArray(this) result(yes)

    Overloaded type bound procedure idDynamicArray%isFilled()

    Arguments

    Type IntentOptional AttributesName
    class(idDynamicArray) :: this

    Return Value logical

    Array is filled

procedure, public :: locationOf => locationOf_idDynamicArray

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

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

    Overloaded type bound procedure idDynamicArray%locationOf().

    Arguments

    Type IntentOptional AttributesName
    class(idDynamicArray) :: this
    integer(kind=i64) :: val

    Get the location of this value

    Return Value integer(kind=i32)

    Location of value

procedure, public :: prepend => prepend_idDynamicArray

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

  • private subroutine prepend_idDynamicArray(this, val)

    Overloaded type bound procedure idDynamicArray%prepend()

    Arguments

    Type IntentOptional AttributesName
    class(idDynamicArray) :: this
    integer(kind=i64) :: val

    Value to prepend.

procedure, public :: reallocate => reallocate_idDynamicArray

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

  • private subroutine reallocate_idDynamicArray(this, M)

    Overloaded type bound procedure idDynamicArray%reallocate().

    Arguments

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

    Reallocate memory to this size.

procedure, public :: remove => remove_idDynamicArray

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

  • private subroutine remove_idDynamicArray(this, i)

    Overloaded type bound procedure idDynamicArray%remove().

    Arguments

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

    Remove the value at this location.

procedure, public :: tighten => tighten_idDynamicArray

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

  • private subroutine tighten_idDynamicArray(this)

    Overloaded type bound procedure idDynamicArray%tighten().

    Arguments

    Type IntentOptional AttributesName
    class(idDynamicArray) :: this