Top Description Inners Fields Constructors Methods
io.netty.util.internal

public final Class DefaultPriorityQueue<T extends PriorityQueueNode>

extends AbstractQueue<T extends PriorityQueueNode>
implements PriorityQueue<T extends PriorityQueueNode>
Class Inheritance
All Implemented Interfaces
io.netty.util.internal.PriorityQueue, java.util.Queue, java.util.Collection, java.lang.Iterable
Type Parameters
<T>
The object that is maintained in the queue.
Imports
java.util.AbstractQueue, .Arrays, .Comparator, .Iterator, .NoSuchElementException

A priority queue which uses natural ordering of elements. Elements are also required to be of type PriorityQueueNode for the purpose of maintaining the index in the priority queue.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final Comparator<T>
private static final PriorityQueueNode[]
private T[]
private int

Constructor Summary

AccessConstructor and Description
public
DefaultPriorityQueue(Comparator<T> comparator, int initialSize)

Method Summary

Modifier and TypeMethod and Description
private void
bubbleDown(int k, T node)

private void
bubbleUp(int k, T node)

public void
clear()

Overrides java.util.AbstractQueue.clear.

Implements java.util.Collection.clear.

Removes all of the elements from this collection (optional operation).
public void
clearIgnoringIndexes()

Implements io.netty.util.internal.PriorityQueue.clearIgnoringIndexes.

Removes all of the elements from this PriorityQueue without calling PriorityQueueNode#priorityQueueIndex(DefaultPriorityQueue) or explicitly removing references to them to allow them to be garbage collected.
public boolean
contains(Object
element whose presence in this collection is to be tested
o
)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Collection.contains.

Returns true if this collection contains the specified element.
private boolean
public boolean
containsTyped(T node)

Implements io.netty.util.internal.PriorityQueue.containsTyped.

Same as contains(Object) but typed using generics.
public boolean
isEmpty()

Overrides java.util.AbstractCollection.isEmpty.

Implements java.util.Collection.isEmpty.

Returns true if this collection contains no elements.
public Iterator<T>
iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Collection.iterator.

This iterator does not return elements in any particular order.
public boolean
offer(T
the element to add
e
)

Implements java.util.Queue.offer.

Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions.
public T
peek()

Implements java.util.Queue.peek.

Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.
public T
poll()

Implements java.util.Queue.poll.

Retrieves and removes the head of this queue, or returns null if this queue is empty.
public void
priorityChanged(T
An object which is in this queue and the priority may have changed.
node
)

Implements io.netty.util.internal.PriorityQueue.priorityChanged.

Notify the queue that the priority for node has changed.
public boolean
remove(Object
element to be removed from this collection, if present
o
)

Overrides java.util.AbstractCollection.remove.

Implements java.util.Collection.remove.

Removes a single instance of the specified element from this collection, if it is present (optional operation).
public boolean
removeTyped(T node)

Implements io.netty.util.internal.PriorityQueue.removeTyped.

Same as remove(Object) but typed using generics.
public int
size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Collection.size.

Returns the number of elements in this collection.
public Object[]
toArray()

Overrides java.util.AbstractCollection.toArray.

Implements java.util.Collection.toArray.

Returns an array containing all of the elements in this collection.
public <X> X[]
toArray(X[]
the array into which the elements of this collection are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
a
)

Overrides java.util.AbstractCollection.toArray.

Implements java.util.Collection.toArray.

Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
Inherited from java.util.AbstractQueue:
addaddAllelementremove

Field Detail

comparatorback to summary
private final Comparator<T> comparator
EMPTY_ARRAYback to summary
private static final PriorityQueueNode[] EMPTY_ARRAY
queueback to summary
private T[] queue
sizeback to summary
private int size

Constructor Detail

DefaultPriorityQueueback to summary
public DefaultPriorityQueue(Comparator<T> comparator, int initialSize)
Annotations
@SuppressWarnings:unchecked

Method Detail

bubbleDownback to summary
private void bubbleDown(int k, T node)
bubbleUpback to summary
private void bubbleUp(int k, T node)
clearback to summary
public void clear()

Overrides java.util.AbstractQueue.clear.

Implements java.util.Collection.clear.

Doc from java.util.Collection.clear.

Removes all of the elements from this collection (optional operation). The collection will be empty after this method returns.

Annotations
@Override
clearIgnoringIndexesback to summary
public void clearIgnoringIndexes()

Implements io.netty.util.internal.PriorityQueue.clearIgnoringIndexes.

Doc from io.netty.util.internal.PriorityQueue.clearIgnoringIndexes.

Removes all of the elements from this PriorityQueue without calling PriorityQueueNode#priorityQueueIndex(DefaultPriorityQueue) or explicitly removing references to them to allow them to be garbage collected. This should only be used when it is certain that the nodes will not be re-inserted into this or any other PriorityQueue and it is known that the PriorityQueue itself will be garbage collected after this call.

Annotations
@Override
containsback to summary
public boolean contains(Object o)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Collection.contains.

Doc from java.util.Collection.contains.

Returns true if this collection contains the specified element. More formally, returns true if and only if this collection contains at least one element e such that Objects.equals(o, e).

Parameters
o:Object

element whose presence in this collection is to be tested

Returns:boolean

true if this collection contains the specified element

Annotations
@Override
containsback to summary
private boolean contains(PriorityQueueNode node, int i)
containsTypedback to summary
public boolean containsTyped(T node)

Implements io.netty.util.internal.PriorityQueue.containsTyped.

Doc from io.netty.util.internal.PriorityQueue.containsTyped.

Same as contains(Object) but typed using generics.

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Overrides java.util.AbstractCollection.isEmpty.

Implements java.util.Collection.isEmpty.

Doc from java.util.Collection.isEmpty.

Returns true if this collection contains no elements.

Returns:boolean

true if this collection contains no elements

Annotations
@Override
iteratorback to summary
public Iterator<T> iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Collection.iterator.

This iterator does not return elements in any particular order.

Returns:Iterator<T>

Doc from java.util.Collection.iterator.

an Iterator over the elements in this collection

Annotations
@Override
offerback to summary
public boolean offer(T e)

Implements java.util.Queue.offer.

Doc from java.util.Queue.offer.

Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions. When using a capacity-restricted queue, this method is generally preferable to add, which can fail to insert an element only by throwing an exception.

Parameters
e:T

the element to add

Returns:boolean

true if the element was added to this queue, else false

Annotations
@Override
peekback to summary
public T peek()

Implements java.util.Queue.peek.

Doc from java.util.Queue.peek.

Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.

Returns:T

the head of this queue, or null if this queue is empty

Annotations
@Override
pollback to summary
public T poll()

Implements java.util.Queue.poll.

Doc from java.util.Queue.poll.

Retrieves and removes the head of this queue, or returns null if this queue is empty.

Returns:T

the head of this queue, or null if this queue is empty

Annotations
@Override
priorityChangedback to summary
public void priorityChanged(T node)

Implements io.netty.util.internal.PriorityQueue.priorityChanged.

Doc from io.netty.util.internal.PriorityQueue.priorityChanged.

Notify the queue that the priority for node has changed. The queue will adjust to ensure the priority queue properties are maintained.

Parameters
node:T

An object which is in this queue and the priority may have changed.

Annotations
@Override
removeback to summary
public boolean remove(Object o)

Overrides java.util.AbstractCollection.remove.

Implements java.util.Collection.remove.

Doc from java.util.Collection.remove.

Removes a single instance of the specified element from this collection, if it is present (optional operation). More formally, removes an element e such that Objects.equals(o, e), if this collection contains one or more such elements. Returns true if this collection contained the specified element (or equivalently, if this collection changed as a result of the call).

Parameters
o:Object

element to be removed from this collection, if present

Returns:boolean

true if an element was removed as a result of this call

Annotations
@SuppressWarnings:unchecked
@Override
removeTypedback to summary
public boolean removeTyped(T node)

Implements io.netty.util.internal.PriorityQueue.removeTyped.

Doc from io.netty.util.internal.PriorityQueue.removeTyped.

Same as remove(Object) but typed using generics.

Annotations
@Override
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Collection.size.

Doc from java.util.Collection.size.

Returns the number of elements in this collection. If this collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of elements in this collection

Annotations
@Override
toArrayback to summary
public Object[] toArray()

Overrides java.util.AbstractCollection.toArray.

Implements java.util.Collection.toArray.

Doc from java.util.Collection.toArray.

Returns an array containing all of the elements in this collection. If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order. The returned array's runtime component type is Object.

The returned array will be "safe" in that no references to it are maintained by this collection. (In other words, this method must allocate a new array even if this collection is backed by an array). The caller is thus free to modify the returned array.

Returns:Object[]

an array, whose runtime component type is Object, containing all of the elements in this collection

Annotations
@Override
toArrayback to summary
public <X> X[] toArray(X[] a)

Overrides java.util.AbstractCollection.toArray.

Implements java.util.Collection.toArray.

Doc from java.util.Collection.toArray.

Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. If the collection fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this collection.

If this collection fits in the specified array with room to spare (i.e., the array has more elements than this collection), the element in the array immediately following the end of the collection is set to null. (This is useful in determining the length of this collection only if the caller knows that this collection does not contain any null elements.)

If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.

Parameters
<X>
the component type of the array to contain the collection
a:X[]

the array into which the elements of this collection are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.

Returns:X[]

an array containing all of the elements in this collection

Annotations
@SuppressWarnings:unchecked
@Override
io.netty.util.internal back to summary

private final Class DefaultPriorityQueue.PriorityQueueIterator

extends Object
implements Iterator<T extends PriorityQueueNode>
Class Inheritance
  • java.lang.Object
  • io.netty.util.internal.DefaultPriorityQueue.PriorityQueueIterator
All Implemented Interfaces
java.util.Iterator

Field Summary

Modifier and TypeField and Description
private int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.
public T
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.
public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

indexback to summary
private int index

Constructor Detail

PriorityQueueIteratorback to summary
private PriorityQueueIterator()

Method Detail

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public T next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:T

the next element in the iteration

Annotations
@Override
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override