Package ghidra.util.datastruct
Class PriorityQueue<T>
- java.lang.Object
-
- ghidra.util.datastruct.PriorityQueue<T>
-
public class PriorityQueue<T> extends java.lang.Object
Maintains a list of objects in priority order where priority is just an integer value. The object with the lowest priority number can be retrieved using getFirst() and the object with the highest priority number can be retrieved using getLast().
-
-
Constructor Summary
Constructors Constructor Description PriorityQueue()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(T obj, int priority)
Adds the given object to the queue at the appropriate insertion point based on the given priority.void
clear()
Removes all objects from the queue.T
getFirst()
Returns the object with the lowest priority number in the queue.java.lang.Integer
getFirstPriority()
Returns the priority of the object with the lowest priority in the queue.T
getLast()
Returns the object with the highest priority number in the queue.java.lang.Integer
getLastPriority()
Returns the priority of the object with the highest priority in the queue.boolean
isEmpty()
Returns true if the queue is empty.T
removeFirst()
Removes and returns the object with the lowest priority number in the queue.T
removeLast()
Removes and returns the object with the highest priority number in the queue.int
size()
Returns the number of objects in the queue.
-
-
-
Method Detail
-
add
public void add(T obj, int priority)
Adds the given object to the queue at the appropriate insertion point based on the given priority.- Parameters:
obj
- the object to be added.priority
- the priority assigned to the object.
-
size
public int size()
Returns the number of objects in the queue.
-
isEmpty
public boolean isEmpty()
Returns true if the queue is empty.
-
getFirst
public T getFirst()
Returns the object with the lowest priority number in the queue. If more than one object has the same priority, then the object that was added to the queue first is considered to have the lower priority value. Null is returned if the queue is empty.
-
getFirstPriority
public java.lang.Integer getFirstPriority()
Returns the priority of the object with the lowest priority in the queue. Null returned if the queue is empty.
-
getLast
public T getLast()
Returns the object with the highest priority number in the queue. If more than one object has the same priority, then the object that was added to the queue last is considered to have the higher priority value. Null is returned if the queue is empty.
-
getLastPriority
public java.lang.Integer getLastPriority()
Returns the priority of the object with the highest priority in the queue. Null returned if the queue is empty.
-
removeFirst
public T removeFirst()
Removes and returns the object with the lowest priority number in the queue. If more than one object has the same priority, then the object that was added to the queue first is considered to have the lower priority value. Null is returned if the queue is empty.- Returns:
- the object with the lowest priority number or null if the list is empty.
-
removeLast
public T removeLast()
Removes and returns the object with the highest priority number in the queue. If more than one object has the same priority, then the object that was added to the queue last is considered to have the higher priority value. Null is returned if the queue is empty.- Returns:
- the object with the highest priority number or null if the list is empty.
-
clear
public void clear()
Removes all objects from the queue.
-
-