tigase.util
Class PriorityQueue<E>

java.lang.Object
  extended by tigase.util.PriorityQueue<E>
Type Parameters:
E -

public class PriorityQueue<E>
extends java.lang.Object

Works like a LinkedBlockingQueue using the put() and take() methods but with an additional priority integer parameter. The elemnt returned from take() will honor the priority in such a way that all elements of a lower priority will be returned before any elemens of a higher priority. Modified proposition taken from Noa Resare: http://resare.com/noa/ref/MultiPrioQueue.java

Version:
$Rev: 1539 $
Author:
Artur Hefczyc

Constructor Summary
PriorityQueue(int maxPriority, int maxSize)
           
 
Method Summary
 boolean offer(E element, int priority)
           
 void put(E element, int priority)
           
 void setMaxSize(int maxSize)
           
 int[] size()
           
 E take()
           
 int totalSize()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PriorityQueue

public PriorityQueue(int maxPriority,
                     int maxSize)
Method Detail

setMaxSize

public void setMaxSize(int maxSize)

put

public void put(E element,
                int priority)
         throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

offer

public boolean offer(E element,
                     int priority)

take

public E take()
       throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

size

public int[] size()

totalSize

public int totalSize()


Copyright © 2009 Tigase. All Rights Reserved.