- java.lang.Object
-
- org.chocosolver.util.objects.PriorityQueue
-
public class PriorityQueue extends Object
- Since:
- 18/04/2014
- Author:
- Charles Prud'homme
-
-
Constructor Summary
Constructors Constructor Description PriorityQueue(int _n)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addElement(int index, int value)
Adds an integer into the list.void
clear()
Clears the list.boolean
isEmpty()
Tests if the list is empty or not.int
pop()
Returns and removes the element with highest priority (i.e. lowest value) in O(1).String
toString()
-
-
-
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.
-
-