Package org.locationtech.jts.util
Class PriorityQueue
java.lang.Object
org.locationtech.jts.util.PriorityQueue
A priority queue over a set of
Comparable objects.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(Comparable x) Insert into the priority queue.voidclear()Make the priority queue logically empty.booleanisEmpty()Test if the priority queue is logically empty.poll()Remove the smallest item from the priority queue.private voidreorder(int hole) Internal method to percolate down in the heap.intsize()Returns size.
-
Field Details
-
size
private int size -
items
-
-
Constructor Details
-
PriorityQueue
public PriorityQueue()Creates a new empty priority queue
-
-
Method Details
-
add
Insert into the priority queue. Duplicates are allowed.- Parameters:
x- the item to insert.
-
isEmpty
public boolean isEmpty()Test if the priority queue is logically empty.- Returns:
- true if empty, false otherwise.
-
size
public int size()Returns size.- Returns:
- current size.
-
clear
public void clear()Make the priority queue logically empty. -
poll
Remove the smallest item from the priority queue.- Returns:
- the smallest item, or null if empty
-
reorder
private void reorder(int hole) Internal method to percolate down in the heap.- Parameters:
hole- the index at which the percolate begins.
-