Type for a maxheap
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 |
Finalizes the maxheap
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(maxheap_t), | intent(inout) | :: | this |
Initialize an empty maxheap Input: max_size - maximum number of elements in the heap
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(maxheap_t), | intent(inout) | :: | this | |||
integer(kind=i4), | intent(in) | :: | max_size |
Adds a new value to the maxheap, with a corresponding index Input: value - the value to add index - the corresponding index of the value
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(maxheap_t), | intent(inout) | :: | this | |||
real(kind=dp), | intent(in) | :: | value | |||
integer(kind=i4), | intent(in) | :: | index |
Removes a value from the maxheap Input: index - the corresponding index of the value
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(maxheap_t), | intent(inout) | :: | this | |||
integer(kind=i4), | intent(in) | :: | index |
Adds a delta weight to an existing index Input: delta_weight - the weight to add index - the corresponding index of the value
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(maxheap_t), | intent(inout) | :: | this | |||
real(kind=dp), | intent(in) | :: | delta_weight | |||
integer(kind=i4), | intent(in) | :: | index |
Prints the contents of the maxheap
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(maxheap_t), | intent(in) | :: | this |
Gets the maximum value from the maxheap
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(maxheap_t), | intent(in) | :: | this |
Gets the original index of the maximum value
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(maxheap_t), | intent(in) | :: | this |