- java.lang.Object
-
- org.logicng.collections.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 booleancontains(int element)Returns whether a given element is already imported and present in the queue or not.booleanempty()Returns whether the queue is empty or not.voidpop()Removes the top element from the priority queue.voidpop(int element)Removes a given element from the priority queue.longpriority(int element)Returns the priority for a given element.voidpush(int element)Pushes a new element to the queue.intsize()Returns the size of the queue.inttop()Returns the top element of the priority queue (= the element with the largest priority).StringtoString()voidupdate(int element, long priority)Updated the priority of a given element.
-
-
-
Method Detail
-
empty
public boolean empty()
Returns whether the queue is empty or not.- Returns:
trueif the queue is empty,falseotherwise
-
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:
trueif 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 elementpriority- 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.
-
-