// Path: src/main/java/org/jheaps/Heap.java
// public interface Heap<K> {
// 
//     /**
//      * Returns the comparator used to order the keys in this heap, or
//      * {@code null} if this heap uses the {@linkplain Comparable natural
//      * ordering} of its keys.
//      *
//      * @return the comparator used to order the keys in this heap, or
//      *         {@code null} if this heap uses the natural ordering of its keys
//      */
//     Comparator<? super K> comparator();
// 
//     /**
//      * Insert a key into the heap.
//      *
//      * @param key
//      *            the key to insert
//      */
//     void insert(K key);
// 
//     /**
//      * Find an element with the minimum key.
//      *
//      * @return an element with the minimum key
//      * @throws NoSuchElementException
//      *             if the heap is empty
//      */
//     K findMin();
// 
//     /**
//      * Delete and return an element with the minimum key. If multiple such
//      * elements exists, only one of them will be deleted.
//      *
//      * @return the deleted element with the minimum key
//      * @throws NoSuchElementException
//      *             if the heap is empty
//      */
//     K deleteMin();
// 
//     /**
//      * Returns {@code true} if this heap is empty.
//      *
//      * @return {@code true} if this heap is empty, {@code false} otherwise
//      */
//     boolean isEmpty();
// 
//     /**
//      * Returns the number of elements in this heap.
//      *
//      * @return the number of elements in this heap
//      */
//     long size();
// 
//     /**
//      * Clear all the elements of this heap.
//      */
//     void clear();
// 
// }


import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Comparator;
import org.jheaps.Heap;
	public void testWithComparator() {

		Heap<Long> h = createHeap(comparator);
		long i;

		for (i = 0; i < SIZE; i++) {
			h.insert(i);
			assertEquals(Long.valueOf(i), h.findMin());
			assertFalse(h.isEmpty());
			assertEquals(h.size(), i + 1);
		}

		for (i = SIZE - 1; i >= 0; i--) {
			assertEquals(h.findMin(), Long.valueOf(i));
			h.deleteMin();
		}

	}

	@Test
	public void testOnly4Reverse() {
		Heap<Long> h = createHeap(comparator);

		assertTrue(h.isEmpty());

		h.insert(780L);
		assertEquals(h.size(), 1);
		assertEquals(Long.valueOf(780), h.findMin());

		h.insert(-389L);
// Path: src/main/java/org/jheaps/Heap.java
// public interface Heap<K> {
// 
//     /**
//      * Returns the comparator used to order the keys in this heap, or
//      * {@code null} if this heap uses the {@linkplain Comparable natural
//      * ordering} of its keys.
//      *
//      * @return the comparator used to order the keys in this heap, or
//      *         {@code null} if this heap uses the natural ordering of its keys
//      */
//     Comparator<? super K> comparator();
// 
//     /**
//      * Insert a key into the heap.
//      *
//      * @param key
//      *            the key to insert
//      */
//     void insert(K key);
// 
//     /**
//      * Find an element with the minimum key.
//      *
//      * @return an element with the minimum key
//      * @throws NoSuchElementException
//      *             if the heap is empty
//      */
//     K findMin();
// 
//     /**
//      * Delete and return an element with the minimum key. If multiple such
//      * elements exists, only one of them will be deleted.
//      *
//      * @return the deleted element with the minimum key
//      * @throws NoSuchElementException
//      *             if the heap is empty
//      */
//     K deleteMin();
// 
//     /**
//      * Returns {@code true} if this heap is empty.
//      *
//      * @return {@code true} if this heap is empty, {@code false} otherwise
//      */
//     boolean isEmpty();
// 
//     /**
//      * Returns the number of elements in this heap.
//      *
//      * @return the number of elements in this heap
//      */
//     long size();
// 
//     /**
//      * Clear all the elements of this heap.
//      */
//     void clear();
// 
// }


// Path: src/test/java/org/jheaps/tree/AbstractComparatorLongHeapTest.java
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Comparator;
import org.jheaps.Heap;

	public void testWithComparator() {

		Heap<Long> h = createHeap(comparator);
		long i;

		for (i = 0; i < SIZE; i++) {
			h.insert(i);
			assertEquals(Long.valueOf(i), h.findMin());
			assertFalse(h.isEmpty());
			assertEquals(h.size(), i + 1);
		}

		for (i = SIZE - 1; i >= 0; i--) {
			assertEquals(h.findMin(), Long.valueOf(i));
			h.deleteMin();
		}

	}

	@Test
	public void testOnly4Reverse() {
		Heap<Long> h = createHeap(comparator);

		assertTrue(h.isEmpty());

		h.insert(780L);
		assertEquals(h.size(), 1);
		assertEquals(Long.valueOf(780), h.findMin());

		h.insert(-389L);
		assertEquals(h.size(), 2);