KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > util > PriorityQueue

java.util
Class PriorityQueue<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractQueue<E>
          extended by java.util.PriorityQueue<E>
All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, Queue<E>
See Also:
Top Examples, PriorityBlockingQueue, iterator(), Iterator, Comparator, Comparable

public boolean add(E o)
See Also:
ClassCastException, NullPointerException, AbstractQueue, Collection
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1381]Quick and Dirty Hackjob demonstrating PriorityQueue
By juunma { at } gmail { dot } com on 2005/04/06 01:01:41  Rate
Quick and Dirty Hackjob demonstrating PriorityQueue's add method add Integers 1-10 on Comparable and then remove them from the head to the end: 
  
  
 import java.util.PriorityQueue; 
  
  
 public class Foo {  
    public static void main ( String args [  ]  )  {  
       PriorityQueue < Integer >  PQ = new PriorityQueue < Integer > ; 
       for ( int i = 0; i  <  10; i++ )  
           PQ.add ( new Integer ( i )  ) ; 
       for ( int i = 0; i  <  10; i++ )  {  
           System.out.println ( "current head is: " + PQ.poll (  )  ) ; 
        }  
     }  
  } 


public void clear()
See Also:
E, AbstractQueue, Collection
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Comparator<? super E> comparator()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Iterator<E> iterator()
See Also:
AbstractCollection, Collection, Iterable
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean offer(E o)
See Also:
NullPointerException, ClassCastException, Queue
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public E peek()
See Also:
Queue
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public E poll()
See Also:
Queue
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public PriorityQueue()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public PriorityQueue(int initialCapacity)
See Also:
IllegalArgumentException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public PriorityQueue(int initialCapacity,
                     Comparator<? super E> comparator)
See Also:
IllegalArgumentException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public PriorityQueue(Collection<? extends E> c)
See Also:
NullPointerException, ClassCastException, SortedSet
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public PriorityQueue(PriorityQueue<? extends E> c)
See Also:
NullPointerException, ClassCastException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public PriorityQueue(SortedSet<? extends E> c)
See Also:
NullPointerException, ClassCastException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean remove(Object o)
See Also:
E, AbstractCollection, Collection
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int size()
See Also:
E, AbstractCollection, Collection
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags