Package it.unimi.dsi.fastutil
Class PriorityQueues.EmptyPriorityQueue
java.lang.Object
it.unimi.dsi.fastutil.PriorityQueues.EmptyPriorityQueue
- All Implemented Interfaces:
PriorityQueue,java.io.Serializable
- Enclosing class:
- PriorityQueues
public static class PriorityQueues.EmptyPriorityQueue extends java.lang.Object implements PriorityQueue, java.io.Serializable
An immutable class representing the empty priority queue.
This class may be useful to implement your own in case you subclass
PriorityQueue.
- See Also:
- Serialized Form
-
Method Summary
Modifier and Type Method Description voidchanged()Notifies the queue that the first element has changed (optional operation).voidclear()Removes all elements from this queue.java.lang.Objectclone()java.util.Comparator<?>comparator()Returns the comparator associated with this queue, ornullif it uses its elements' natural ordering.java.lang.Objectdequeue()Dequeues the first element from the queue.voidenqueue(java.lang.Object o)Enqueues a new element.booleanequals(java.lang.Object o)java.lang.Objectfirst()Returns the first element of the queue.inthashCode()booleanisEmpty()Checks whether this queue is empty.java.lang.Objectlast()Returns the last element of the queue, that is, the element the would be dequeued last (optional operation).intsize()Returns the number of elements in this queue.Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
-
Method Details
-
enqueue
public void enqueue(java.lang.Object o)Description copied from interface:PriorityQueueEnqueues a new element.- Specified by:
enqueuein interfacePriorityQueue- Parameters:
o- the element to enqueue.
-
dequeue
public java.lang.Object dequeue()Description copied from interface:PriorityQueueDequeues the first element from the queue.- Specified by:
dequeuein interfacePriorityQueue- Returns:
- the dequeued element.
-
isEmpty
public boolean isEmpty()Description copied from interface:PriorityQueueChecks whether this queue is empty.This default implementation checks whether
PriorityQueue.size()is zero.- Specified by:
isEmptyin interfacePriorityQueue- Returns:
- true if this queue is empty.
-
size
public int size()Description copied from interface:PriorityQueueReturns the number of elements in this queue.- Specified by:
sizein interfacePriorityQueue- Returns:
- the number of elements in this queue.
-
clear
public void clear()Description copied from interface:PriorityQueueRemoves all elements from this queue.- Specified by:
clearin interfacePriorityQueue
-
first
public java.lang.Object first()Description copied from interface:PriorityQueueReturns the first element of the queue.- Specified by:
firstin interfacePriorityQueue- Returns:
- the first element.
-
last
public java.lang.Object last()Description copied from interface:PriorityQueueReturns the last element of the queue, that is, the element the would be dequeued last (optional operation).This default implementation just throws an
UnsupportedOperationException.- Specified by:
lastin interfacePriorityQueue- Returns:
- the last element.
-
changed
public void changed()Description copied from interface:PriorityQueueNotifies the queue that the first element has changed (optional operation).This default implementation just throws an
UnsupportedOperationException.- Specified by:
changedin interfacePriorityQueue
-
comparator
public java.util.Comparator<?> comparator()Description copied from interface:PriorityQueueReturns the comparator associated with this queue, ornullif it uses its elements' natural ordering.- Specified by:
comparatorin interfacePriorityQueue- Returns:
- the comparator associated with this sorted set, or
nullif it uses its elements' natural ordering.
-
clone
public java.lang.Object clone() -
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equalsin classjava.lang.Object
-