public class IdPriorityQueue extends IntSet
| Modifier and Type | Field and Description |
|---|---|
protected int |
highestIndex
stores highest index
|
protected double[] |
priorities
Holds the priorities
|
| Constructor and Description |
|---|
IdPriorityQueue()
Constructor with capacity 10
|
IdPriorityQueue(int capacity)
Constructor with initial capacity
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(int v)
Adds the element
|
void |
add(int i,
double priority)
Adds an id to the queue or updates its priority
|
void |
addAll(IdPriorityQueue s) |
void |
clear(int capacity) |
protected int |
highestIndex()
Returns the index with highest priority
|
double |
highestPriority()
Returns the highest priority
|
static void |
main(String[] args)
Test
|
int |
peek()
Returns the id with the highest priority
|
int |
poll()
Returns and removes the id with highest priority
|
void |
put(long id,
double priority)
Truncates the id to int, then adds (linear time)
|
boolean |
remove(int i)
Removes one element, returns TRUE if the set was modified
|
protected void |
shrink()
Shrinks the set space if it is too large
|
String |
toString() |
add, add, add, addAll, addAll, addAll, addTo, clear, contains, contains, contains, containsAll, enhancedBy, enhancedBy, indexOf, isEmpty, iterator, of, remove, remove, removeAll, removeAll, removeAll, removeIndex, retainAll, setTo, shrunkBy, shrunkBy, size, toArray, toArrayclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitequals, hashCode, spliteratorparallelStream, removeIf, streamprotected double[] priorities
protected int highestIndex
public IdPriorityQueue(int capacity)
public IdPriorityQueue()
public void add(int i,
double priority)
public void put(long id,
double priority)
protected int highestIndex()
public int poll()
protected void shrink()
public double highestPriority()
public int peek()
public boolean remove(int i)
IntSetpublic void addAll(IdPriorityQueue s)
public boolean add(int v)
IntSetpublic static void main(String[] args)
Copyright © 2018. All rights reserved.