|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractQueue<E>
java.util.PriorityQueue<Integer>
com.browseengine.bobo.util.IntBoundedPriorityQueue
public class IntBoundedPriorityQueue
A priority queue for int that uses int[] heap for storage. Always have least element on top. When the queue is full, new elements are added if they are bigger than the least element to replace them.
| Nested Class Summary | |
|---|---|
static class |
IntBoundedPriorityQueue.IntComparator
|
static interface |
IntBoundedPriorityQueue.IntIterator
|
| Constructor Summary | |
|---|---|
IntBoundedPriorityQueue(IntBoundedPriorityQueue.IntComparator comparator,
int capacity,
int forbiddenValue)
|
|
| Method Summary | |
|---|---|
Integer |
element()
Retrieves, but does not remove, the head of this queue. |
int |
intElement()
|
IntBoundedPriorityQueue.IntIterator |
iterator()
Returns an iterator over the elements in this collection. |
boolean |
offer(int item)
When the queue is full, the offered elements are added if they are bigger than the smallest one already in the queue. |
boolean |
offer(Integer item)
When the queue is full, the offered elements are added if they are bigger than the smallest one already in the queue. |
Integer |
peek()
Retrieves, but does not remove, the head of this queue, returning null if this queue is empty. |
int |
peekInt()
Retrieves, but does not remove, the head of this queue, returning the forbidden value if the queue is empty. |
Integer |
poll()
Retrieves and removes the head of this queue, or null if this queue is empty. |
int |
pollInt()
Retrieves and removes the head of this queue, or the forbidden value if this queue is empty. |
int |
size()
Returns the number of elements in this collection. |
| Methods inherited from class java.util.PriorityQueue |
|---|
add, clear, comparator, contains, remove, toArray, toArray |
| Methods inherited from class java.util.AbstractQueue |
|---|
addAll, remove |
| Methods inherited from class java.util.AbstractCollection |
|---|
containsAll, isEmpty, removeAll, retainAll, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Collection |
|---|
containsAll, equals, hashCode, isEmpty, removeAll, retainAll |
| Constructor Detail |
|---|
public IntBoundedPriorityQueue(IntBoundedPriorityQueue.IntComparator comparator,
int capacity,
int forbiddenValue)
capacity - the maximum number of items the queue acceptscomparator - a comparator that is used to order the items.| Method Detail |
|---|
public Integer element()
throws NoSuchElementException
element in interface Queue<Integer>element in class AbstractQueue<Integer>NoSuchElementExceptionQueue.element()
public int intElement()
throws NoSuchElementException
NoSuchElementExceptionpublic IntBoundedPriorityQueue.IntIterator iterator()
iterator in interface Iterable<Integer>iterator in interface Collection<Integer>iterator in class PriorityQueue<Integer>AbstractCollection.iterator()public boolean offer(Integer item)
offer in interface Queue<Integer>offer in class PriorityQueue<Integer>Queue.offer(java.lang.Object)public boolean offer(int item)
Queue.offer(java.lang.Object)public Integer peek()
peek in interface Queue<Integer>peek in class PriorityQueue<Integer>Queue.peek()public int peekInt()
public Integer poll()
poll in interface Queue<Integer>poll in class PriorityQueue<Integer>Queue.poll()public int pollInt()
public int size()
size in interface Collection<Integer>size in class PriorityQueue<Integer>AbstractCollection.size()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||