MinMaxHeap extends AbstractHeap implements IMinMaxHeap<IResetableComparable> { public boolean isEmpty() { return numEntry == 0; } MinMaxHeap(IResetableComparableFactory factory, int capacity); @Override void getMin(IResetableComparable result); @Override void getMax(IResetableComparable result); boolean isEmpty(); @Override void peekMin(IResetableComparable result); @Override void peekMax(IResetableComparable result); @Override void replaceMin(IResetableComparable newElement); @Override void replaceMax(IResetableComparable newElement);  }
@Test public void testInitialMinMaxHeap() { int capacity = 10; MinMaxHeap minHeap = new MinMaxHeap(new IntFactory(), capacity); assertTrue(minHeap.isEmpty()); assertEquals(0, minHeap.getNumEntries()); }
@Test public void testInsertElements() { int capacity = 10; MinMaxHeap minMaxHeap = new MinMaxHeap(new IntFactory(), capacity); for (int i = 0; i < capacity * 10; i++) { minMaxHeap.insert(new Int(random.nextInt())); } assertEquals(capacity * 10, minMaxHeap.getNumEntries()); assertFalse(minMaxHeap.isEmpty()); assertGetMinHeapIsSorted(minMaxHeap); for (int i = 0; i < capacity * 10; i++) { minMaxHeap.insert(new Int(random.nextInt())); } assertEquals(capacity * 10, minMaxHeap.getNumEntries()); assertGetMaxHeapIsSorted(minMaxHeap); }