ReadonlylinksMax heap with links and their priorities
ReadonlyurlData structure to track URLs in the queue and allow for constant time lookup of links in queue based on link URL
Bubbles down the element at input index until max-heap property is satisifed
Index of element to down-heap
The number of links in the queue.
If no links are in the queue.
Function to change priority of element of heap with certain number. Based on whether the delta is positive or negative, we upheap or downheap.
Get (but not remove) the next link from the queue.
Pops the highest priority link and returns it. Then it sets the last element as root and down-heaps it.
popped element
Pushes element to heap by appending it to array and up-heaping the new element
Changes all priorities in queue in O(n + m*log m ) time, with n is size of urlPriorities entry and m size of the queue. Will only update priorities of urls that are actually in queue.
A record with url and new priority
Update priority of link in queue if it is in queue
URL of link to update
new priority value
boolean indicating if priority was changed successfully
Bubbles up the element at index until the max-heap property is satifisfied
Index of element to up-heap
A link queue based on priority, using binary heap.