|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnetkit.util.UpdatablePriorityQueue<E>
public class UpdatablePriorityQueue<E>
Constructor Summary | |
---|---|
UpdatablePriorityQueue()
Creates a PriorityQueue with the default initial
capacity (11) that orders its elements according to their
natural ordering. |
|
UpdatablePriorityQueue(int initialCapacity)
Creates a PriorityQueue with the specified initial
capacity that orders its elements according to their
natural ordering. |
|
UpdatablePriorityQueue(int initialCapacity,
java.util.Comparator<? super E> comparator)
Creates a PriorityQueue with the specified initial capacity
that orders its elements according to the specified comparator. |
Method Summary | ||
---|---|---|
netkit.util.UpdatablePriorityQueue.QueueElement |
add(E e)
Inserts the specified element into this priority queue. |
|
void |
clear()
Removes all of the elements from this priority queue. |
|
java.util.Comparator<? super E> |
comparator()
Returns the comparator used to order the elements in this queue, or null if this queue is sorted according to
the natural ordering of its elements. |
|
boolean |
contains(E o)
Returns true if this queue contains the specified element. |
|
boolean |
isEmpty()
|
|
java.util.Iterator<E> |
iterator()
Returns an iterator over the elements in this queue. |
|
E |
peek()
|
|
E |
poll()
|
|
boolean |
remove(E o)
Removes a single instance of the specified element from this queue, if it is present. |
|
boolean |
remove(netkit.util.UpdatablePriorityQueue.QueueElement qe)
Removes a single instance of the specified element from this queue, if it is present. |
|
int |
size()
|
|
java.lang.Object[] |
toArray()
Returns an array containing all of the elements in this queue. |
|
|
toArray(T[] a)
Returns an array containing all of the elements in this queue; the runtime type of the returned array is that of the specified array. |
|
void |
update(netkit.util.UpdatablePriorityQueue.QueueElement qe)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UpdatablePriorityQueue()
PriorityQueue
with the default initial
capacity (11) that orders its elements according to their
natural ordering.
public UpdatablePriorityQueue(int initialCapacity)
PriorityQueue
with the specified initial
capacity that orders its elements according to their
natural ordering.
initialCapacity
- the initial capacity for this priority queue
java.lang.IllegalArgumentException
- if initialCapacity
is less
than 1public UpdatablePriorityQueue(int initialCapacity, java.util.Comparator<? super E> comparator)
PriorityQueue
with the specified initial capacity
that orders its elements according to the specified comparator.
initialCapacity
- the initial capacity for this priority queuecomparator
- the comparator that will be used to order this
priority queue. If null
, the natural ordering of the elements will be used.
java.lang.IllegalArgumentException
- if initialCapacity
is
less than 1Method Detail |
---|
public netkit.util.UpdatablePriorityQueue.QueueElement add(E e)
true
(as specified by Collection.add(E)
)
java.lang.ClassCastException
- if the specified element cannot be
compared with elements currently in this priority queue
according to the priority queue's ordering
java.lang.NullPointerException
- if the specified element is nullpublic E peek()
public void update(netkit.util.UpdatablePriorityQueue.QueueElement qe)
public boolean remove(netkit.util.UpdatablePriorityQueue.QueueElement qe)
e
such
that o.equals(e)
, if this queue contains one or more such
elements. Returns true
if and only if this queue contained
the specified element (or equivalently, if this queue changed as a
result of the call).
qe
- element to be removed from this queue, if present
true
if this queue changed as a result of the callpublic boolean remove(E o)
e
such
that o.equals(e)
, if this queue contains one or more such
elements. Returns true
if and only if this queue contained
the specified element (or equivalently, if this queue changed as a
result of the call).
o
- element to be removed from this queue, if present
true
if this queue changed as a result of the callpublic boolean isEmpty()
public boolean contains(E o)
true
if this queue contains the specified element.
More formally, returns true
if and only if this queue contains
at least one element e
such that o.equals(e)
.
o
- object to be checked for containment in this queue
true
if this queue contains the specified elementpublic java.lang.Object[] toArray()
The returned array will be "safe" in that no references to it are maintained by this queue. (In other words, this method must allocate a new array). The caller is thus free to modify the returned array.
This method acts as bridge between array-based and collection-based APIs.
public <T> T[] toArray(T[] a)
If the queue fits in the specified array with room to spare
(i.e., the array has more elements than the queue), the element in
the array immediately following the end of the collection is set to
null
.
Like the toArray()
method, this method acts as bridge between
array-based and collection-based APIs. Further, this method allows
precise control over the runtime type of the output array, and may,
under certain circumstances, be used to save allocation costs.
Suppose x is a queue known to contain only strings. The following code can be used to dump the queue into a newly allocated array of String:
String[] y = x.toArray(new String[0]);Note that toArray(new Object[0]) is identical in function to toArray().
a
- the array into which the elements of the queue are to
be stored, if it is big enough; otherwise, a new array of the
same runtime type is allocated for this purpose.
java.lang.ArrayStoreException
- if the runtime type of the specified array
is not a supertype of the runtime type of every element in
this queue
java.lang.NullPointerException
- if the specified array is nullpublic java.util.Iterator<E> iterator()
iterator
in interface java.lang.Iterable<E>
public int size()
public void clear()
public E poll()
public java.util.Comparator<? super E> comparator()
null
if this queue is sorted according to
the natural ordering of its elements.
null
if this queue is sorted according to the
natural ordering of its elements
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |