How to implement a generic PriorityQueue with basic methods in java?
<p>I need to implement a custom priority queue without using the PriorityQueue form Java.Util... I have three basic methods : insert, remove and clear . All operations must be done in constant time O (log n). How can I accomplish this ? What algorithms should I use for these operations ? And lastly, what type of container should I use in which to keep the generic values ?</p>

<p>This is what I've done so far ... </p>

<pre><code>public class PriorityQueue&lt;E extends Comparable&lt;? super E&gt;&gt; implements Comparable {
    private Stack&lt;E&gt; queue = new Stack&lt;&gt;();
    private int size;


    public PriorityQueue(int size) {
        this.size = size;
    }

    public PriorityQueue() {
        size = 50000;
    }

    public void insert(E value) {
        if (value == null) {
            throw new NullPointerException();
        }
        //how can I insert a value and what container should I use ?

    }

    public void remove() {
        //remove largest
    }

    public int compareTo(Object o) {
        if (o != null &amp;&amp; o instanceof PriorityQueue) {
            PriorityQueue anotherQueue = (PriorityQueue) o;
            return this.size - anotherQueue.size;
        } else {
            throw new ClassCastException();
        }
    }
}
</code></pre>

<p>not much.. but help would be greatly appreciated ! </p>