Package org.jheaps
Interface MergeableDoubleEndedAddressableHeap<K,V>
-
- Type Parameters:
K
- the type of keys maintained by this heapV
- the type of values maintained by this heap
- All Superinterfaces:
AddressableHeap<K,V>
,DoubleEndedAddressableHeap<K,V>
- All Known Implementing Classes:
ReflectedFibonacciHeap
,ReflectedHeap
,ReflectedPairingHeap
public interface MergeableDoubleEndedAddressableHeap<K,V> extends DoubleEndedAddressableHeap<K,V>
A double-ended addressable heap that allows melding with another double-ended addressable heap.The second heap becomes empty and unusable after the meld operation, meaning than further insertions are not possible and will throw an
IllegalStateException
.A
ClassCastException
will be thrown if the two heaps are not of the same type. Moreover, the two heaps need to use the same comparators. If only one of them uses a custom comparator or both use custom comparators but are not the same by equals, anIllegalArgumentException
is thrown.Note that all running time bounds on mergeable heaps are valid assuming that the user does not perform cascading melds on heaps such as:
d.meld(e); c.meld(d); b.meld(c); a.meld(b);
The above scenario, although efficiently supported by using union-find with path compression, invalidates the claimed bounds.- Author:
- Dimitrios Michail
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jheaps.DoubleEndedAddressableHeap
DoubleEndedAddressableHeap.Handle<K,V>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
meld(MergeableDoubleEndedAddressableHeap<K,V> other)
Meld a heap into the current heap.-
Methods inherited from interface org.jheaps.AddressableHeap
clear, comparator, isEmpty, size
-
-
-
-
Method Detail
-
meld
void meld(MergeableDoubleEndedAddressableHeap<K,V> other)
Meld a heap into the current heap. After the operation theother
heap will be empty and will not permit further insertions.- Parameters:
other
- a merge-able heap- Throws:
ClassCastException
- ifother
is not compatible with this heapIllegalArgumentException
- ifother
does not have a compatible comparator
-
-