datastructs_maxheap_mod Module

This module implements a maxheap structure, keeping track of the maximum value and its index. Example:

program example_maxheap
    use datastructs_fortran
    use kinds_mod
    implicit none
    type(maxheap_t) :: my_heap
    real(kind=dp), parameter :: list(*) = [40.0_dp,25.5_dp,30.1_dp,100.4_dp,2.0_dp]
    integer(kind=i4) :: i

    call my_heap%init(10)

    do i = 1, size(list)
        call my_heap%add(list(i), i)
    end do

    call my_heap%print()

    call my_heap%remove(4)

    call my_heap%print()
end program example_maxheap

Uses

  • module~~datastructs_maxheap_mod~~UsesGraph module~datastructs_maxheap_mod datastructs_maxheap_mod module~datastructs_kinds_mod datastructs_kinds_mod module~datastructs_maxheap_mod->module~datastructs_kinds_mod iso_fortran_env iso_fortran_env module~datastructs_kinds_mod->iso_fortran_env

Used by

  • module~~datastructs_maxheap_mod~~UsedByGraph module~datastructs_maxheap_mod datastructs_maxheap_mod module~datastructs_lists_mod datastructs_lists_mod module~datastructs_lists_mod->module~datastructs_maxheap_mod module~datastructs_mod datastructs_mod module~datastructs_mod->module~datastructs_lists_mod module~datastructs_samplers_rejection_maxheap_composition_mod datastructs_samplers_rejection_maxheap_composition_mod module~datastructs_samplers_rejection_maxheap_composition_mod->module~datastructs_lists_mod module~datastructs_samplers_rejection_maxheap_mod datastructs_samplers_rejection_maxheap_mod module~datastructs_samplers_rejection_maxheap_composition_mod->module~datastructs_samplers_rejection_maxheap_mod module~datastructs_samplers_rejection_maxheap_mod->module~datastructs_lists_mod module~datastructs_samplers_rejection_maxheap_two_classes_mod datastructs_samplers_rejection_maxheap_two_classes_mod module~datastructs_samplers_rejection_maxheap_two_classes_mod->module~datastructs_lists_mod module~datastructs_samplers_rejection_maxheap_two_classes_mod->module~datastructs_samplers_rejection_maxheap_mod module~datastructs_samplers_rejection_mod datastructs_samplers_rejection_mod module~datastructs_samplers_rejection_mod->module~datastructs_lists_mod module~datastructs_samplers_rejection_two_classes_mod datastructs_samplers_rejection_two_classes_mod module~datastructs_samplers_rejection_two_classes_mod->module~datastructs_lists_mod module~datastructs_samplers_rejection_two_classes_mod->module~datastructs_samplers_rejection_mod proc~choose_sampler choose_sampler proc~choose_sampler->module~datastructs_samplers_rejection_maxheap_composition_mod proc~choose_sampler->module~datastructs_samplers_rejection_maxheap_mod proc~choose_sampler->module~datastructs_samplers_rejection_maxheap_two_classes_mod proc~choose_sampler->module~datastructs_samplers_rejection_mod proc~choose_sampler->module~datastructs_samplers_rejection_two_classes_mod

Interfaces

public interface maxheap

Constructor for a maxheap

  • private function maxheap_new(max_size) result(this)

    Create a new maxheap Input: max_size - maximum number of elements in the heap

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=i4) :: max_size

    Return Value type(maxheap_t)


Derived Types

type, public ::  maxheap_t

Type for a maxheap

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

Finalizations Procedures

final :: maxheap_finalize

Type-Bound Procedures

procedure, public :: init => maxheap_init
procedure, public :: add => maxheap_add
procedure, public :: remove => maxheap_remove
procedure, public :: add_weight => maxheap_add_weight
procedure, public :: print => maxheap_print
procedure, public :: max_value => maxheap_max_value
procedure, public :: max_index => maxheap_max_index