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 void
changed()
Notifies the queue that the first element has changed (optional operation).void
clear()
Removes all elements from this queue.java.lang.Object
clone()
java.util.Comparator<?>
comparator()
Returns the comparator associated with this queue, ornull
if it uses its elements' natural ordering.java.lang.Object
dequeue()
Dequeues the first element from the queue.void
enqueue(java.lang.Object o)
Enqueues a new element.boolean
equals(java.lang.Object o)
java.lang.Object
first()
Returns the first element of the queue.int
hashCode()
boolean
isEmpty()
Checks whether this queue is empty.java.lang.Object
last()
Returns the last element of the queue, that is, the element the would be dequeued last (optional operation).int
size()
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:PriorityQueue
Enqueues a new element.- Specified by:
enqueue
in interfacePriorityQueue
- Parameters:
o
- the element to enqueue.
-
dequeue
public java.lang.Object dequeue()Description copied from interface:PriorityQueue
Dequeues the first element from the queue.- Specified by:
dequeue
in interfacePriorityQueue
- Returns:
- the dequeued element.
-
isEmpty
public boolean isEmpty()Description copied from interface:PriorityQueue
Checks whether this queue is empty.This default implementation checks whether
PriorityQueue.size()
is zero.- Specified by:
isEmpty
in interfacePriorityQueue
- Returns:
- true if this queue is empty.
-
size
public int size()Description copied from interface:PriorityQueue
Returns the number of elements in this queue.- Specified by:
size
in interfacePriorityQueue
- Returns:
- the number of elements in this queue.
-
clear
public void clear()Description copied from interface:PriorityQueue
Removes all elements from this queue.- Specified by:
clear
in interfacePriorityQueue
-
first
public java.lang.Object first()Description copied from interface:PriorityQueue
Returns the first element of the queue.- Specified by:
first
in interfacePriorityQueue
- Returns:
- the first element.
-
last
public java.lang.Object last()Description copied from interface:PriorityQueue
Returns 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:
last
in interfacePriorityQueue
- Returns:
- the last element.
-
changed
public void changed()Description copied from interface:PriorityQueue
Notifies the queue that the first element has changed (optional operation).This default implementation just throws an
UnsupportedOperationException
.- Specified by:
changed
in interfacePriorityQueue
-
comparator
public java.util.Comparator<?> comparator()Description copied from interface:PriorityQueue
Returns the comparator associated with this queue, ornull
if it uses its elements' natural ordering.- Specified by:
comparator
in interfacePriorityQueue
- Returns:
- the comparator associated with this sorted set, or
null
if it uses its elements' natural ordering.
-
clone
public java.lang.Object clone() -
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equals
in classjava.lang.Object
-