Package io.netty.util.internal
Class DefaultPriorityQueue<T extends PriorityQueueNode>
java.lang.Object
java.util.AbstractCollection<T>
java.util.AbstractQueue<T>
io.netty.util.internal.DefaultPriorityQueue<T>
- Type Parameters:
T
- The object that is maintained in the queue.
- All Implemented Interfaces:
PriorityQueue<T>
,Iterable<T>
,Collection<T>
,Queue<T>
public final class DefaultPriorityQueue<T extends PriorityQueueNode>
extends AbstractQueue<T>
implements PriorityQueue<T>
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 Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Comparator
<T> private static final PriorityQueueNode[]
private T[]
private int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
bubbleDown
(int k, T node) private void
void
clear()
void
Removes all of the elements from thisPriorityQueue
without callingPriorityQueueNode.priorityQueueIndex(DefaultPriorityQueue)
or explicitly removing references to them to allow them to be garbage collected.private boolean
contains
(PriorityQueueNode node, int i) boolean
boolean
containsTyped
(T node) Same asCollection.contains(Object)
but typed using generics.boolean
isEmpty()
iterator()
This iterator does not return elements in any particular order.boolean
peek()
poll()
void
priorityChanged
(T node) Notify the queue that the priority fornode
has changed.boolean
boolean
removeTyped
(T node) Same asCollection.remove(Object)
but typed using generics.int
size()
Object[]
toArray()
<X> X[]
toArray
(X[] a) Methods inherited from class java.util.AbstractQueue
add, addAll, element, remove
Methods inherited from class java.util.AbstractCollection
containsAll, 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
addAll, containsAll, equals, hashCode, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray
-
Field Details
-
EMPTY_ARRAY
-
comparator
-
queue
-
size
private int size
-
-
Constructor Details
-
DefaultPriorityQueue
-
-
Method Details
-
size
public int size()- Specified by:
size
in interfaceCollection<T extends PriorityQueueNode>
- Specified by:
size
in classAbstractCollection<T extends PriorityQueueNode>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<T extends PriorityQueueNode>
- Overrides:
isEmpty
in classAbstractCollection<T extends PriorityQueueNode>
-
contains
- Specified by:
contains
in interfaceCollection<T extends PriorityQueueNode>
- Overrides:
contains
in classAbstractCollection<T extends PriorityQueueNode>
-
containsTyped
Description copied from interface:PriorityQueue
Same asCollection.contains(Object)
but typed using generics.- Specified by:
containsTyped
in interfacePriorityQueue<T extends PriorityQueueNode>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<T extends PriorityQueueNode>
- Overrides:
clear
in classAbstractQueue<T extends PriorityQueueNode>
-
clearIgnoringIndexes
public void clearIgnoringIndexes()Description copied from interface:PriorityQueue
Removes all of the elements from thisPriorityQueue
without callingPriorityQueueNode.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 otherPriorityQueue
and it is known that thePriorityQueue
itself will be garbage collected after this call.- Specified by:
clearIgnoringIndexes
in interfacePriorityQueue<T extends PriorityQueueNode>
-
offer
- Specified by:
offer
in interfaceQueue<T extends PriorityQueueNode>
-
poll
- Specified by:
poll
in interfaceQueue<T extends PriorityQueueNode>
-
peek
- Specified by:
peek
in interfaceQueue<T extends PriorityQueueNode>
-
remove
- Specified by:
remove
in interfaceCollection<T extends PriorityQueueNode>
- Overrides:
remove
in classAbstractCollection<T extends PriorityQueueNode>
-
removeTyped
Description copied from interface:PriorityQueue
Same asCollection.remove(Object)
but typed using generics.- Specified by:
removeTyped
in interfacePriorityQueue<T extends PriorityQueueNode>
-
priorityChanged
Description copied from interface:PriorityQueue
Notify the queue that the priority fornode
has changed. The queue will adjust to ensure the priority queue properties are maintained.- Specified by:
priorityChanged
in interfacePriorityQueue<T extends PriorityQueueNode>
- Parameters:
node
- An object which is in this queue and the priority may have changed.
-
toArray
- Specified by:
toArray
in interfaceCollection<T extends PriorityQueueNode>
- Overrides:
toArray
in classAbstractCollection<T extends PriorityQueueNode>
-
toArray
public <X> X[] toArray(X[] a) - Specified by:
toArray
in interfaceCollection<T extends PriorityQueueNode>
- Overrides:
toArray
in classAbstractCollection<T extends PriorityQueueNode>
-
iterator
This iterator does not return elements in any particular order.- Specified by:
iterator
in interfaceCollection<T extends PriorityQueueNode>
- Specified by:
iterator
in interfaceIterable<T extends PriorityQueueNode>
- Specified by:
iterator
in classAbstractCollection<T extends PriorityQueueNode>
-
contains
-
bubbleDown
-
bubbleUp
-