Module logicng

Class LNGLongPriorityQueue


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

      Constructors 
      Constructor Description
      LNGLongPriorityQueue()
      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.
      long priority​(int element)
      Returns the priority for a given element.
      void push​(int element)
      Pushes a new element to the queue.
      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, long priority)
      Updated the priority of a given element.
    • Constructor Detail

      • LNGLongPriorityQueue

        public LNGLongPriorityQueue()
        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 long 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 element to the queue.
        Parameters:
        element - the element
        Throws:
        IllegalArgumentException - if the element to add is negative
      • update

        public void update​(int element,
                           long 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.