Package org.chocosolver.util.objects
Class PriorityQueue
- 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 booleanaddElement(int index, int value)Adds an integer into the list.voidclear()Clears the list.booleanisEmpty()Tests if the list is empty or not.intpop()Returns and removes the element with highest priority (i.e. lowest value) in O(1).StringtoString()
-
-
-
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:
trueif 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:
trueif and only if the list is empty.
-
clear
public void clear()
Clears the list.
-
-