javatools.datatypes
Class IdPriorityQueue

java.lang.Object
  extended by javatools.datatypes.IntSet
      extended by javatools.datatypes.IdPriorityQueue
All Implemented Interfaces:
java.lang.Iterable<java.lang.Integer>, java.util.Collection<java.lang.Integer>, java.util.Set<java.lang.Integer>

public class IdPriorityQueue
extends IntSet

This class is part of the Java Tools (see http://mpii.de/yago-naga/javatools). It is licensed under the Creative Commons Attribution License (see http://creativecommons.org/licenses/by/3.0) by the YAGO-NAGA team (see http://mpii.de/yago-naga). This class implements a priority queue, whose elements are integers (ids) and whose priorities are doubles.


Constructor Summary
IdPriorityQueue()
          Constructor with capacity 10
IdPriorityQueue(int capacity)
          Constructor with initial capacity
 
Method Summary
 boolean add(int v)
          Adds the element
 void add(int i, double priority)
          Adds an id to the queue or updates its priority
 void addAll(IdPriorityQueue s)
           
 void clear(int capacity)
           
 double highestPriority()
          Returns the highest priority
static void main(java.lang.String[] args)
          Test
 int peek()
          Returns the id with the highest priority
 int poll()
          Returns and removes the id with highest priority
 void put(long id, double priority)
          Truncates the id to int, then adds (linear time)
 boolean remove(int i)
          Removes one element, returns TRUE if the set was modified
 java.lang.String toString()
           
 
Methods inherited from class javatools.datatypes.IntSet
add, add, add, addAll, addAll, addAll, addTo, clear, contains, contains, contains, containsAll, enhancedBy, enhancedBy, isEmpty, iterator, of, remove, remove, removeAll, removeAll, removeAll, retainAll, setTo, shrunkBy, shrunkBy, size, toArray, toArray
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
equals, hashCode
 

Constructor Detail

IdPriorityQueue

public IdPriorityQueue(int capacity)
Constructor with initial capacity


IdPriorityQueue

public IdPriorityQueue()
Constructor with capacity 10

Method Detail

add

public void add(int i,
                double priority)
Adds an id to the queue or updates its priority


put

public void put(long id,
                double priority)
Truncates the id to int, then adds (linear time)


poll

public int poll()
Returns and removes the id with highest priority

Overrides:
poll in class IntSet

highestPriority

public double highestPriority()
Returns the highest priority


peek

public int peek()
Returns the id with the highest priority


remove

public boolean remove(int i)
Description copied from class: IntSet
Removes one element, returns TRUE if the set was modified

Overrides:
remove in class IntSet

clear

public void clear(int capacity)
Overrides:
clear in class IntSet

addAll

public void addAll(IdPriorityQueue s)

add

public boolean add(int v)
Description copied from class: IntSet
Adds the element

Overrides:
add in class IntSet

toString

public java.lang.String toString()
Overrides:
toString in class IntSet

main

public static void main(java.lang.String[] args)
Test