Returns and removes the first heap element and rebalances the heap.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dbcsr_heap_type), | intent(inout) | :: | heap | |||
integer(kind=keyt), | intent(out) | :: | key | |||
integer(kind=valt), | intent(out) | :: | value | |||
logical, | intent(out) | :: | found |
SUBROUTINE dbcsr_heap_pop(heap, key, value, found) !! Returns and removes the first heap element and rebalances !! the heap. TYPE(dbcsr_heap_type), INTENT(INOUT) :: heap INTEGER(KIND=keyt), INTENT(OUT) :: key INTEGER(KIND=valt), INTENT(OUT) :: value LOGICAL, INTENT(OUT) :: found ! CALL dbcsr_heap_get_first(heap, key, value, found) IF (found) THEN IF (heap%n .GT. 1) THEN CALL dbcsr_heap_copy_node(heap, 1, heap%n) heap%n = heap%n - 1 CALL bubble_down(heap, 1) ELSE heap%n = heap%n - 1 END IF END IF END SUBROUTINE dbcsr_heap_pop