|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.limegroup.gnutella.util.FixedsizePriorityQueue
A priority queue with bounded size. Similar to BinaryHeap, but implemented with a balanced tree instead of a binary heap. This results in some subtle differences:
BinaryHeap| Constructor Summary | |
FixedsizePriorityQueue(java.util.Comparator comparator,
int capacity)
Creates a new FixedsizePriorityQueue that will hold at most capacity elements. |
|
| Method Summary | |
int |
capacity()
Returns the maximum number of elements this can hold. |
boolean |
contains(java.lang.Object o)
Returns true if this contains o. |
java.lang.Object |
getMax()
Returns the highest priority element of this. |
java.lang.Object |
getMin()
Returns the lowest priority element of this. |
java.lang.Object |
insert(java.lang.Object x)
Adds x to this, possibly removing some lower priority entry if necessary to ensure this.size()<=this.capacity(). |
java.util.Iterator |
iterator()
Returns an iterator of the elements in this, from worst to best. |
boolean |
remove(java.lang.Object o)
Removes the first occurence of o. |
protected void |
repOk()
|
int |
size()
Returns the number of elements in this. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public FixedsizePriorityQueue(java.util.Comparator comparator,
int capacity)
throws java.lang.IllegalArgumentException
comparator - expresses priority. Note that
comaparator.compareTo(a,b)==0 does not imply that a.equals(b).capacity - the maximum number of elements
java.lang.IllegalArgumentException - capacity negative| Method Detail |
public java.lang.Object insert(java.lang.Object x)
x - the entry to add
public java.lang.Object getMax()
throws java.util.NoSuchElementException
java.util.NoSuchElementException - this.size()==0
public java.lang.Object getMin()
throws java.util.NoSuchElementException
java.util.NoSuchElementException - this.size()==0public boolean contains(java.lang.Object o)
public boolean remove(java.lang.Object o)
public java.util.Iterator iterator()
public int size()
public int capacity()
protected void repOk()
public java.lang.String toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||