Package ghidra.util.datastruct
Class PriorityQueue<T>
java.lang.Object
ghidra.util.datastruct.PriorityQueue<T>
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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.getFirst()
Returns the object with the lowest priority number in the queue.Returns the priority of the object with the lowest priority in the queue.getLast()
Returns the object with the highest priority number in the queue.Returns the priority of the object with the highest priority in the queue.boolean
isEmpty()
Returns true if the queue is empty.Removes and returns the object with the lowest priority number in the queue.Removes and returns the object with the highest priority number in the queue.int
size()
Returns the number of objects in the queue.
-
Constructor Details
-
PriorityQueue
public PriorityQueue()
-
-
Method Details
-
add
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
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
Returns the priority of the object with the lowest priority in the queue. Null returned if the queue is empty. -
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
Returns the priority of the object with the highest priority in the queue. Null returned if the queue is empty. -
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
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.
-