code: @SuppressWarnings("unchecked")
      @Override
      public void meld(MergeableDoubleEndedAddressableHeap<K, V> other) {
          ReflectedHeap<K, V> h = (ReflectedHeap<K, V>) other;
  
          // check same comparator
          if (comparator != null) {
              if (h.comparator == null || !h.comparator.equals(comparator)) {
                  throw new IllegalArgumentException("Cannot meld heaps using different comparators!");
              }
          } else if (h.comparator != null) {
              throw new IllegalArgumentException("Cannot meld heaps using different comparators!");
          }
  
          if (h.other != h) {
              throw new IllegalStateException("A heap cannot be used after a meld.");
          }
  
          if (!(minHeap instanceof MergeableAddressableHeap)) {
              throw new IllegalArgumentException("Underlying heaps are not meldable.");
          }
  
          // meld min heaps
          MergeableAddressableHeap<K, V> minAsMergeableHeap = (MergeableAddressableHeap<K, V>) minHeap;
          MergeableAddressableHeap<K, V> hMinAsMergeableHeap = (MergeableAddressableHeap<K, V>) h.minHeap;
          minAsMergeableHeap.meld(hMinAsMergeableHeap);
  
          // meld max heaps
          MergeableAddressableHeap<K, V> maxAsMergeableHeap = (MergeableAddressableHeap<K, V>) maxHeap;
          MergeableAddressableHeap<K, V> hMaxAsMergeableHeap = (MergeableAddressableHeap<K, V>) h.maxHeap;
          maxAsMergeableHeap.meld(hMaxAsMergeableHeap);
  
          // meld free
          if (free == null) {
              if (h.free != null) {
                  free = h.free;
                  h.free = null;
              }
          } else {
              if (h.free != null) {
                  insertPair(free, h.free);
                  h.free = null;
                  free = null;
              }
          }
  
          // set new sizes
          size += h.size;
          h.size = 0;
  
          // take ownership
          h.other = this;
      }
docs: {@inheritDoc}