Page Speed Optimization Libraries
1.13.35.1
|
Public Member Functions | |
void | IncreasePriority (const T &key, int64 amount) |
void | Increment (const T &key) |
Eqivalent to IncreasePriority(key, 1). | |
void | Remove (const T &key) |
Remove a given element. Silently succeeds if the element isn't present. More... | |
const std::pair< const T *, int64 > & | Top () const |
Return the key with the highest priority, and its priority. | |
void | Pop () |
Remove the key with the highest priority from the queue. More... | |
bool | Empty () const |
size_t | Size () const |
void | Clear () |
Friends | |
class | PriorityQueueTest |
void net_instaweb::PriorityQueue< T, Hash, Equal >::IncreasePriority | ( | const T & | key, |
int64 | amount | ||
) |
Increase the priority of "key" by amount. If key is not already present, it will be inserted at priority amount. amount may be negative.
Is key already stored?
Insert new entry at the end of the queue.
Now put key in the index.
< No existing entry.
void net_instaweb::PriorityQueue< T, Hash, Equal >::Pop | ( | ) |
Remove the key with the highest priority from the queue.
Swap the first and last entries in the queue. If there is only one entry in the queue, this swaps 0 and 0.
Remove the old top entry off the back of the queue. First find the key for the old top and remove it from the queue.
Remove the key from index_map_.
Free the key.
Finally, restore heap property by re-balancing the entry we just put into the first position. It is possible that we are empty at this point.
void net_instaweb::PriorityQueue< T, Hash, Equal >::Remove | ( | const T & | key | ) |
Remove a given element. Silently succeeds if the element isn't present.
Key not present, do nothing.
Swap the value being removed with the value at the back. If there is only one entry in the queue, this swaps 0 and 0.
Remove/delete the old entry.