public final class IntPriorityQueue extends Object
Constructor and Description |
---|
IntPriorityQueue() |
Modifier and Type | Method and Description |
---|---|
int |
addPriority(int i,
int amount)
the priority of i is now the old priority (or 0) + the amount.
|
int |
getPriority(int i)
accesses the priority of i.
|
int |
getTop()
access the element with highest priority, or 0 if it is empty
|
boolean |
isEmpty()
checks if the priority queue is empty
|
int |
percolateDown(int i)
equivalent to addPriority(i, -1);
|
int |
percolateUp(int i)
equivalent to addPriority(i, 1)
|
void |
remove(int i)
forget about i.
|
public int addPriority(int i, int amount)
i
- the int of which we want to modify the priorityamount
- the amount by which we modify the prioritypublic int percolateUp(int i)
i
- the int of which we want to modify the prioritypublic int percolateDown(int i)
i
- the int of which we want to modify the prioritypublic int getPriority(int i)
i
- the intpublic void remove(int i)
i
- the int to forgetpublic int getTop()
public boolean isEmpty()
Copyright © 2022. All rights reserved.