Class PriorityQueue

  • All Implemented Interfaces:
    RevisionHandler

    public class PriorityQueue
    extends java.lang.Object
    implements RevisionHandler

    PriorityQueue.java
    Authors: Rainer Holzmann, Zhanna Melnikova-Albrecht, Matthias Schubert
    Date: Aug 27, 2004
    Time: 5:36:35 PM
    $ Revision 1.4 $

    Version:
    $Revision: 1.3 $
    Author:
    Matthias Schubert (schubert@dbs.ifi.lmu.de), Zhanna Melnikova-Albrecht (melnikov@cip.ifi.lmu.de), Rainer Holzmann (holzmann@cip.ifi.lmu.de)
    • Constructor Summary

      Constructors 
      Constructor Description
      PriorityQueue()
      Creates a new PriorityQueue backed on a binary heap.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(double priority, java.lang.Object o)
      Adds a new Object to the queue
      double getPriority​(int index)
      Returns the priority for the object at the specified index
      java.lang.String getRevision()
      Returns the revision string.
      boolean hasNext()
      Tests, if the queue has some more elements left
      PriorityQueueElement next()
      Returns the element with the highest priority
      int size()
      Returns the queue's size
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PriorityQueue

        public PriorityQueue()
        Creates a new PriorityQueue backed on a binary heap. The queue is dynamically growing and shrinking and it is descending, that is: the highest priority is always in the root.
    • Method Detail

      • add

        public void add​(double priority,
                        java.lang.Object o)
        Adds a new Object to the queue
        Parameters:
        priority - The priority associated with the object
        o -
      • getPriority

        public double getPriority​(int index)
        Returns the priority for the object at the specified index
        Parameters:
        index - the index of the object
        Returns:
        priority
      • size

        public int size()
        Returns the queue's size
        Returns:
        size
      • hasNext

        public boolean hasNext()
        Tests, if the queue has some more elements left
        Returns:
        true, if there are any elements left, else false
      • next

        public PriorityQueueElement next()
        Returns the element with the highest priority
        Returns:
        next element
      • getRevision

        public java.lang.String getRevision()
        Returns the revision string.
        Specified by:
        getRevision in interface RevisionHandler
        Returns:
        the revision