// Path: src/main/java/org/jheaps/AddressableHeap.java
// interface Handle<K, V> {
// 
//     /**
//      * Return the key of the element.
//      *
//      * @return the key of the element
//      */
//     K getKey();
// 
//     /**
//      * Return the value of the element.
//      *
//      * @return the value of the element
//      */
//     V getValue();
// 
//     /**
//      * Set the value of the element.
//      * 
//      * @param value
//      *            the new value
//      */
//     void setValue(V value);
// 
//     /**
//      * Decrease the key of the element.
//      *
//      * @param newKey
//      *            the new key
//      * @throws IllegalArgumentException
//      *             if the new key is larger than the old key according to
//      *             the comparator used when constructing the heap or the
//      *             natural ordering of the elements if no comparator was
//      *             used
//      */
//     void decreaseKey(K newKey);
// 
//     /**
//      * Delete the element from the heap that it belongs.
//      *
//      * @throws IllegalArgumentException
//      *             in case this function is called twice on the same element
//      *             or the element has already been deleted using
//      *             {@link AddressableHeap#deleteMin()}.
//      */
//     void delete();
// 
// }
// 
// Path: src/main/java/org/jheaps/MergeableDoubleEndedAddressableHeap.java
// public interface MergeableDoubleEndedAddressableHeap<K, V> extends DoubleEndedAddressableHeap<K, V> {
// 
//     /**
//      * Meld a heap into the current heap.
//      *
//      * After the operation the {@code other} heap will be empty and will not
//      * permit further insertions.
//      *
//      * @param other
//      *            a merge-able heap
//      * @throws ClassCastException
//      *             if {@code other} is not compatible with this heap
//      * @throws IllegalArgumentException
//      *             if {@code other} does not have a compatible comparator
//      */
//     void meld(MergeableDoubleEndedAddressableHeap<K, V> other);
// 
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.Serializable;
import java.util.Comparator;
import org.jheaps.AddressableHeap.Handle;
import org.jheaps.MergeableDoubleEndedAddressableHeap;
import org.junit.BeforeClass;
import org.junit.Test;
        b.insert(15);
        b.insert(16);
        Handle<Integer, String> b4 = b.insert(17);

        MergeableDoubleEndedAddressableHeap<Integer, String> c = createHeap();
        c.insert(18);
        c.insert(19);
        c.insert(20);
        Handle<Integer, String> c4 = c.insert(21);

        a.meld(b);
        a.meld(c);

        assertEquals(12, a.size());
        assertTrue(b.isEmpty());
        assertEquals(0, b.size());

        assertTrue(c.isEmpty());
        assertEquals(0, c.size());

        assertEquals(Integer.valueOf(10), a.findMin().getKey());
        b4.decreaseKey(9);
        assertEquals(Integer.valueOf(9), a.findMin().getKey());
        c4.decreaseKey(8);
        assertEquals(Integer.valueOf(8), a.findMin().getKey());
    }

    @Test(expected = IllegalStateException.class)
    public void testMultipleMelds() {
        MergeableDoubleEndedAddressableHeap<Integer, String> a = createHeap();
// Path: src/main/java/org/jheaps/AddressableHeap.java
// interface Handle<K, V> {
// 
//     /**
//      * Return the key of the element.
//      *
//      * @return the key of the element
//      */
//     K getKey();
// 
//     /**
//      * Return the value of the element.
//      *
//      * @return the value of the element
//      */
//     V getValue();
// 
//     /**
//      * Set the value of the element.
//      * 
//      * @param value
//      *            the new value
//      */
//     void setValue(V value);
// 
//     /**
//      * Decrease the key of the element.
//      *
//      * @param newKey
//      *            the new key
//      * @throws IllegalArgumentException
//      *             if the new key is larger than the old key according to
//      *             the comparator used when constructing the heap or the
//      *             natural ordering of the elements if no comparator was
//      *             used
//      */
//     void decreaseKey(K newKey);
// 
//     /**
//      * Delete the element from the heap that it belongs.
//      *
//      * @throws IllegalArgumentException
//      *             in case this function is called twice on the same element
//      *             or the element has already been deleted using
//      *             {@link AddressableHeap#deleteMin()}.
//      */
//     void delete();
// 
// }
// 
// Path: src/main/java/org/jheaps/MergeableDoubleEndedAddressableHeap.java
// public interface MergeableDoubleEndedAddressableHeap<K, V> extends DoubleEndedAddressableHeap<K, V> {
// 
//     /**
//      * Meld a heap into the current heap.
//      *
//      * After the operation the {@code other} heap will be empty and will not
//      * permit further insertions.
//      *
//      * @param other
//      *            a merge-able heap
//      * @throws ClassCastException
//      *             if {@code other} is not compatible with this heap
//      * @throws IllegalArgumentException
//      *             if {@code other} does not have a compatible comparator
//      */
//     void meld(MergeableDoubleEndedAddressableHeap<K, V> other);
// 
// }


// Path: src/test/java/org/jheaps/tree/AbstractMergeableDoubleEndedAddressableHeapTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.Serializable;
import java.util.Comparator;
import org.jheaps.AddressableHeap.Handle;
import org.jheaps.MergeableDoubleEndedAddressableHeap;
import org.junit.BeforeClass;
import org.junit.Test;

        b.insert(15);
        b.insert(16);
        Handle<Integer, String> b4 = b.insert(17);

        MergeableDoubleEndedAddressableHeap<Integer, String> c = createHeap();
        c.insert(18);
        c.insert(19);
        c.insert(20);
        Handle<Integer, String> c4 = c.insert(21);

        a.meld(b);
        a.meld(c);

        assertEquals(12, a.size());
        assertTrue(b.isEmpty());
        assertEquals(0, b.size());

        assertTrue(c.isEmpty());
        assertEquals(0, c.size());

        assertEquals(Integer.valueOf(10), a.findMin().getKey());
        b4.decreaseKey(9);
        assertEquals(Integer.valueOf(9), a.findMin().getKey());
        c4.decreaseKey(8);
        assertEquals(Integer.valueOf(8), a.findMin().getKey());
    }

    @Test(expected = IllegalStateException.class)
    public void testMultipleMelds() {
        MergeableDoubleEndedAddressableHeap<Integer, String> a = createHeap();
        a.insert(10);