org.xnap.util
Class PriorityQueue

java.lang.Object
  extended by org.xnap.util.PriorityQueue

public class PriorityQueue
extends java.lang.Object

A list of Object objects that is sorted descending by priority.

This class is thread safe.


Field Summary
protected  java.util.LinkedList queue
           
 
Constructor Summary
PriorityQueue()
           
 
Method Summary
 void add(java.lang.Object o, int priority)
          Adds o.
 boolean addUnique(java.lang.Object o, int priority)
          Adds o if not already in queue.
 void clear()
           
 boolean isEmpty()
           
 java.util.Iterator iterator()
           
 java.lang.Object peek()
          Returns the item with the highest priority without removing it.
 java.lang.Object pop()
          Removes and returns the item with the highest priority.
 boolean remove(java.lang.Object o)
           
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queue

protected java.util.LinkedList queue
Constructor Detail

PriorityQueue

public PriorityQueue()
Method Detail

add

public void add(java.lang.Object o,
                int priority)
Adds o.


addUnique

public boolean addUnique(java.lang.Object o,
                         int priority)
Adds o if not already in queue.


clear

public void clear()

isEmpty

public boolean isEmpty()

iterator

public java.util.Iterator iterator()

peek

public java.lang.Object peek()
Returns the item with the highest priority without removing it.


pop

public java.lang.Object pop()
Removes and returns the item with the highest priority.


remove

public boolean remove(java.lang.Object o)

size

public int size()


Copyright © 2001-2005 XNap Team. All Rights Reserved.