Module logicng

Class LNGDoublePriorityQueue


  • public final class LNGDoublePriorityQueue
    extends Object
    A simple priority queue implementation for positive integer elements with double priorities taken from CleaneLing.
    Since:
    1.0
    Version:
    1.3
    • Constructor Summary

      Constructors 
      Constructor Description
      LNGDoublePriorityQueue()
      Creates a new priority queue.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean contains​(int element)
      Returns whether a given element is already imported and present in the queue or not.
      boolean empty()
      Returns whether the queue is empty or not.
      void pop()
      Removes the top element from the priority queue.
      void pop​(int element)
      Removes a given element from the priority queue.
      double priority​(int element)
      Returns the priority for a given element.
      void push​(int element)
      Pushes a new positive element to the queue.
      void rescore​(double factor)
      Rescores all priorities by multiplying them with the same factor.
      int size()
      Returns the size of the queue.
      int top()
      Returns the top element of the priority queue (= the element with the largest priority).
      String toString()  
      void update​(int element, double priority)
      Updated the priority of a given element.
    • Constructor Detail

      • LNGDoublePriorityQueue

        public LNGDoublePriorityQueue()
        Creates a new priority queue.
    • Method Detail

      • empty

        public boolean empty()
        Returns whether the queue is empty or not.
        Returns:
        true if the queue is empty, false otherwise
      • size

        public int size()
        Returns the size of the queue.
        Returns:
        the size of the queue
      • contains

        public boolean contains​(int element)
        Returns whether a given element is already imported and present in the queue or not.
        Parameters:
        element - the element
        Returns:
        true if the element is already imported and present in the queue, false otherwise.
      • priority

        public double priority​(int element)
        Returns the priority for a given element.
        Parameters:
        element - the element
        Returns:
        the priority of the element
      • top

        public int top()
        Returns the top element of the priority queue (= the element with the largest priority).
        Returns:
        the top element of the priority queue
      • push

        public void push​(int element)
        Pushes a new positive element to the queue.
        Parameters:
        element - the element
        Throws:
        IllegalArgumentException - if the element to add is negative
      • update

        public void update​(int element,
                           double priority)
        Updated the priority of a given element.
        Parameters:
        element - the element
        priority - the new priority
      • pop

        public void pop​(int element)
        Removes a given element from the priority queue. Its priority is kept as is.
        Parameters:
        element - the element
      • pop

        public void pop()
        Removes the top element from the priority queue.
      • rescore

        public void rescore​(double factor)
        Rescores all priorities by multiplying them with the same factor.
        Parameters:
        factor - the factor to multiply with