Interface AdjustableHeap<T>
- Type Parameters:
T
- The type of elements stored in the heap.
- All Known Implementing Classes:
AdjustableBinaryHeap
An adjustable heap is a binary heap that allows for efficient adjustments of element priorities.
This interface provides methods to increase or decrease the priority of existing elements in the heap while maintaining the heap property defined by the comparator.
Depending on the implementation the adjustable heap maintains a partial ordering, also known as a "weak ordering," among its elements. Unlike traditional binary heaps, this heap does not require a total order relation among elements. As a result, the element's relative priority may not be strictly determined with respect to other elements.
The adjustable heap implementation is not thread-safe, and it does not allow duplicate elements. The provided comparator should be consistent with equals() and hashcode() to ensure correct behavior.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
decreaseKey
(T item, T decreasedItem) Try to decreaseitem
if it's present in this heap.boolean
increaseKey
(T item, T increasedItem) Try to increaseitem
if it's present in this heap.
-
Method Details
-
increaseKey
Try to increaseitem
if it's present in this heap.- Parameters:
item
- to be increasedincreasedItem
- increasing item- Returns:
- true if item is present and successfully increased
-
decreaseKey
Try to decreaseitem
if it's present in this heap.- Parameters:
item
- to be decreaseddecreasedItem
- decreasing item- Returns:
- true if item is present and successfully decreased
-