@Test public void testFullArray() { final Heap<Integer> smallHeap = new ArrayHeap<>(3); smallHeap.enqueue(1); smallHeap.enqueue(2); smallHeap.enqueue(3); assertThatThrownBy(() -> smallHeap.enqueue(4)) .isInstanceOf(IllegalStateException.class); }
@Override public void enqueue(final T value) { if (size >= array.length) { throw new IllegalStateException("Heap is already full."); } array[size] = value; fixHeapBottomUp(size); size++; }
ArrayHeap implements Heap<T> { @Override public void enqueue(final T value) { if (size >= array.length) { throw new IllegalStateException("Heap is already full."); } array[size] = value; fixHeapBottomUp(size); size++; } }
ArrayHeap implements Heap<T> { @Override public void enqueue(final T value) { if (size >= array.length) { throw new IllegalStateException("Heap is already full."); } array[size] = value; fixHeapBottomUp(size); size++; } ArrayHeap(final int maxSize); }
ArrayHeap implements Heap<T> { @Override public void enqueue(final T value) { if (size >= array.length) { throw new IllegalStateException("Heap is already full."); } array[size] = value; fixHeapBottomUp(size); size++; } ArrayHeap(final int maxSize); @Override void enqueue(final T value); @Override T dequeueMinimum(); @Override T peekMinimum(); @Override int size(); }
ArrayHeap implements Heap<T> { @Override public void enqueue(final T value) { if (size >= array.length) { throw new IllegalStateException("Heap is already full."); } array[size] = value; fixHeapBottomUp(size); size++; } ArrayHeap(final int maxSize); @Override void enqueue(final T value); @Override T dequeueMinimum(); @Override T peekMinimum(); @Override int size();  }