/** ****************************************************************************** * HOMEWORK 15-211 COMPRESSION ****************************************************************************** * * This class lmplements a binary min-heap. * * It does not permit Null elements. * * * @author * @date *****************************************************************************/ /***************************************************************************** IMPLEMENT THIS CLASS *****************************************************************************/ import java.util.*; public class PriorityQueue> implements Iterable { private static final int DEFAULT_INITIAL_CAPACITY = 11; private T[] heap; //new array private int size; //current size of the queue /** * Creates a PriorityQueue with the default initial capacity (11) * that orders its elements according to their natural ordering (using * Comparable). */ public PriorityQueue () { throw new RuntimeException("You must implement this method"); } /** * Creates a PriorityQueue with the specified initial capacity * that orders its elements according to the specified comparator. * * @param initialCapacity * the initial capacity for this priority queue. */ @SuppressWarnings("unchecked") public PriorityQueue (int initialCapacity) { throw new RuntimeException("You must implement this method"); } /** * Constructs a PriorityQueue from the given array in linear time * * @param items the initial items in the binary heap. * * @throws ClassCastException * if elements of the specified collection cannot be compared to * one another according to the priority queue's ordering. * * @throws NullPointerException * if items or any element within it is null */ @SuppressWarnings("unchecked") public PriorityQueue (T[] items) { throw new RuntimeException("You must implement this method"); } /** * Returns the number of elements in this queue. * * @return returns the number of elements in this queue. */ public int size () { throw new RuntimeException("You must implement this method"); } /** * Inserts the specified element into this priority queue. * * @throws NullPointerException * if the specified element is null. */ public void insert (T toInsert) { throw new RuntimeException("You must implement this method"); } /** * Retrieves and removes the head of this queue, or null if this queue is empty. * * @return the head of this queue, or null if this queue is empty. */ public T deleteMin () { throw new RuntimeException("You must implement this method"); } /** * Retrieves, but does not remove, the head of this queue, or null if this queue is empty. * * @return the head of this queue, or null if this queue is empty. */ public T peek () { throw new RuntimeException("You must implement this method"); } /******************************************************* * * The Iterator class * ********************************************************/ /** * Returns an iterator over the elements in this queue. The iterator does * not return the elements in any particular order. The iterator does not * support the remove operation. * * @return an iterator over the elements in this queue. */ public Iterator iterator () { throw new RuntimeException("You must implement this method"); } }