Code example for PriorityQueue

Methods: peek, size

0
 
    /** 
     * @tests java.util.PriorityQueue#peek() 
     */ 
    public void test_peek_empty() { 
        PriorityQueue<Object> queue = new PriorityQueue<Object>();
        assertEquals(0, queue.size());
        assertNull(queue.peek());
        assertNull(queue.peek());
    } 
 
    /** 
     * @tests java.util.PriorityQueue#Clear() 
     */ 
    public void test_clear() { 
        PriorityQueue<Integer> integerQueue = new PriorityQueue<Integer>();
        int[] array = { 2, 45, 7, -12, 9 };
        for (int i = 0; i < array.length; i++) {
            integerQueue.offer(array[i]);
        } 
        integerQueue.clear();