Class PriorityQueue


  • public class PriorityQueue
    extends Object

    Since:
    18/04/2014
    Author:
    Charles Prud'homme
    • Constructor Detail

      • PriorityQueue

        public PriorityQueue​(int _n)
    • Method Detail

      • addElement

        public boolean addElement​(int index,
                                  int value)
        Adds an integer into the list. The element is inserted at its right place (the list is sorted) in O(n).
        Parameters:
        index - the element to insert.
        value - the value to be used for the comparison of the elements to add.
        Returns:
        true if and only if the list is not full.
      • pop

        public int pop()
        Returns and removes the element with highest priority (i.e. lowest value) in O(1).
        Returns:
        the lowest element.
      • isEmpty

        public boolean isEmpty()
        Tests if the list is empty or not.
        Returns:
        true if and only if the list is empty.
      • clear

        public void clear()
        Clears the list.