java.lang.Objectorg.supermind.crawl.HostQueuePriorityQueue
public class HostQueuePriorityQueue
A HostQueuePriorityQueue maintains a partial ordering of its elements such that the least element can always be found in constant time. Put()'s and pop()'s require log(size) time.
Constructor Summary | |
---|---|
HostQueuePriorityQueue(int maxSize)
|
Method Summary | |
---|---|
void |
adjustDown(HostQueue hq)
|
void |
adjustTop()
Should be called when the Object at top changes values. |
void |
adjustUp(HostQueue hq)
|
void |
clear()
Removes all entries from the HostQueuePriorityQueue. |
protected void |
downHeap(int i)
|
protected void |
initialize(int maxSize)
Subclass constructors must call this. |
void |
insert(HostQueue element)
Adds element to the HostQueuePriorityQueue in log(size) time. |
protected boolean |
lessThan(HostQueue a,
HostQueue b)
Determines the ordering of objects in this priority queue. |
HostQueue |
pop()
Removes and returns the least element of the HostQueuePriorityQueue in log(size) time. |
void |
put(HostQueue element)
Adds an Object to a HostQueuePriorityQueue in log(size) time. |
int |
size()
Returns the number of elements currently stored in the HostQueuePriorityQueue. |
HostQueue |
top()
Returns the least element of the HostQueuePriorityQueue in constant time. |
protected void |
upHeap(int i)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HostQueuePriorityQueue(int maxSize)
Method Detail |
---|
public void adjustDown(HostQueue hq)
public final void adjustTop()
{ pq.top().change(); pq.adjustTop(); }instead of
{ o = pq.pop(); o.change(); pq.push(o); }
public void adjustUp(HostQueue hq)
public final void clear()
protected final void downHeap(int i)
protected final void initialize(int maxSize)
public void insert(HostQueue element)
element
- protected boolean lessThan(HostQueue a, HostQueue b)
public final HostQueue pop()
public final void put(HostQueue element)
public final int size()
public final HostQueue top()
protected final void upHeap(int i)