Module io.netty5.common
Package io.netty5.util.internal
Class DefaultPriorityQueue<T extends PriorityQueueNode>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractQueue<T>
-
- io.netty5.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 typePriorityQueueNode
for the purpose of maintaining the index in the priority queue.
-
-
Constructor Summary
Constructors Constructor Description DefaultPriorityQueue(Comparator<T> comparator, int initialSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
void
clearIgnoringIndexes()
Removes all of the elements from thisPriorityQueue
without callingPriorityQueueNode.priorityQueueIndex(DefaultPriorityQueue)
or explicitly removing references to them to allow them to be garbage collected.boolean
contains(Object o)
boolean
containsTyped(T node)
Same asCollection.contains(Object)
but typed using generics.boolean
isEmpty()
Iterator<T>
iterator()
This iterator does not return elements in any particular order.boolean
offer(T e)
T
peek()
T
poll()
void
priorityChanged(T node)
Notify the queue that the priority fornode
has changed.boolean
remove(Object o)
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
-
-
-
-
Constructor Detail
-
DefaultPriorityQueue
public DefaultPriorityQueue(Comparator<T> comparator, int initialSize)
-
-
Method Detail
-
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
public boolean contains(Object o)
- Specified by:
contains
in interfaceCollection<T extends PriorityQueueNode>
- Overrides:
contains
in classAbstractCollection<T extends PriorityQueueNode>
-
containsTyped
public boolean containsTyped(T node)
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
public boolean offer(T e)
- Specified by:
offer
in interfaceQueue<T extends PriorityQueueNode>
-
poll
public T poll()
- Specified by:
poll
in interfaceQueue<T extends PriorityQueueNode>
-
peek
public T peek()
- Specified by:
peek
in interfaceQueue<T extends PriorityQueueNode>
-
remove
public boolean remove(Object o)
- Specified by:
remove
in interfaceCollection<T extends PriorityQueueNode>
- Overrides:
remove
in classAbstractCollection<T extends PriorityQueueNode>
-
removeTyped
public boolean removeTyped(T node)
Description copied from interface:PriorityQueue
Same asCollection.remove(Object)
but typed using generics.- Specified by:
removeTyped
in interfacePriorityQueue<T extends PriorityQueueNode>
-
priorityChanged
public void priorityChanged(T node)
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
public Object[] 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
public Iterator<T> 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>
-
-