maxheap_t Derived Type

type, public :: maxheap_t

Type for a maxheap


Inherited by

type~~maxheap_t~~InheritedByGraph type~maxheap_t maxheap_t type~weighted_sampler_t~2 weighted_sampler_t type~weighted_sampler_t~2->type~maxheap_t heap type~weighted_sampler_t~4 weighted_sampler_t type~weighted_sampler_t~4->type~weighted_sampler_t~2 samplers type~weighted_sampler_t~6 weighted_sampler_t type~weighted_sampler_t~6->type~weighted_sampler_t~2 samplers

Components

Type Visibility Attributes Name Initial
real(kind=dp), public, allocatable :: values(:)
integer(kind=i4), public, allocatable :: indices(:)
integer(kind=i4), public, allocatable :: pos_of(:)
integer(kind=i4), public :: n = 0
integer(kind=i4), public :: max_n

Finalization Procedures

final :: maxheap_finalize

  • private subroutine maxheap_finalize(this)

    Finalizes the maxheap

    Arguments

    Type IntentOptional Attributes Name
    type(maxheap_t), intent(inout) :: this

Type-Bound Procedures

procedure, public :: init => maxheap_init

  • private subroutine maxheap_init(this, max_size)

    Initialize an empty maxheap Input: max_size - maximum number of elements in the heap

    Arguments

    Type IntentOptional Attributes Name
    class(maxheap_t), intent(inout) :: this
    integer(kind=i4), intent(in) :: max_size

procedure, public :: add => maxheap_add

  • private subroutine maxheap_add(this, value, index)

    Adds a new value to the maxheap, with a corresponding index Input: value - the value to add index - the corresponding index of the value

    Arguments

    Type IntentOptional Attributes Name
    class(maxheap_t), intent(inout) :: this
    real(kind=dp), intent(in) :: value
    integer(kind=i4), intent(in) :: index

procedure, public :: remove => maxheap_remove

  • private subroutine maxheap_remove(this, index)

    Removes a value from the maxheap Input: index - the corresponding index of the value

    Arguments

    Type IntentOptional Attributes Name
    class(maxheap_t), intent(inout) :: this
    integer(kind=i4), intent(in) :: index

procedure, public :: add_weight => maxheap_add_weight

  • private subroutine maxheap_add_weight(this, delta_weight, index)

    Adds a delta weight to an existing index Input: delta_weight - the weight to add index - the corresponding index of the value

    Arguments

    Type IntentOptional Attributes Name
    class(maxheap_t), intent(inout) :: this
    real(kind=dp), intent(in) :: delta_weight
    integer(kind=i4), intent(in) :: index

procedure, public :: print => maxheap_print

  • private subroutine maxheap_print(this)

    Prints the contents of the maxheap

    Arguments

    Type IntentOptional Attributes Name
    class(maxheap_t), intent(in) :: this

procedure, public :: max_value => maxheap_max_value

  • private function maxheap_max_value(this) result(value)

    Gets the maximum value from the maxheap

    Arguments

    Type IntentOptional Attributes Name
    class(maxheap_t), intent(in) :: this

    Return Value real(kind=dp)

procedure, public :: max_index => maxheap_max_index

  • private function maxheap_max_index(this) result(index)

    Gets the original index of the maximum value

    Arguments

    Type IntentOptional Attributes Name
    class(maxheap_t), intent(in) :: this

    Return Value integer(kind=i4)