E - the element typepublic class PriorityQueue<E>
extends java.lang.Object
implements java.util.Queue<E>
| Modifier | Constructor and Description |
|---|---|
protected |
PriorityQueue(boolean isMinQueue)
instantiates a new priority queue
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e) |
void |
add(E element,
double priority)
Adds a new element with a defined priority
|
boolean |
addAll(java.util.Collection<? extends E> c) |
void |
clear() |
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(java.util.Collection<?> c) |
E |
element() |
boolean |
isEmpty() |
boolean |
isMaxQueue()
indicates if the queue has a max-queue configuration
|
boolean |
isMinQueue()
indicates if the queue has a min-queue configuration
|
java.util.Iterator<E> |
iterator() |
static <T> PriorityQueue<T> |
maxQueue()
creates a new max-priority-queue
|
static <T> PriorityQueue<T> |
minQueue()
creates a new min-priority-queue
|
boolean |
offer(E e) |
E |
peek() |
E |
poll() |
E |
remove() |
boolean |
remove(java.lang.Object o) |
boolean |
removeAll(java.util.Collection<?> c) |
boolean |
retainAll(java.util.Collection<?> c) |
void |
setPriority(E element,
double priority)
Sets the priority of an element in the queue
|
int |
size() |
java.lang.Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitprotected PriorityQueue(boolean isMinQueue)
isMinQueue - true if the queue should be a min queue, false
if it should be a max queuepublic static <T> PriorityQueue<T> maxQueue()
T - the type of the queuepublic static <T> PriorityQueue<T> minQueue()
T - the type of the queuepublic boolean add(E e)
public void add(E element, double priority)
element - the elementpriority - the prioritypublic boolean addAll(java.util.Collection<? extends E> c)
addAll in interface java.util.Collection<E>public void clear()
clear in interface java.util.Collection<E>public boolean contains(java.lang.Object o)
contains in interface java.util.Collection<E>public boolean containsAll(java.util.Collection<?> c)
containsAll in interface java.util.Collection<E>public boolean isEmpty()
isEmpty in interface java.util.Collection<E>public boolean isMaxQueue()
true iff the queue is a max-queue
1.2public boolean isMinQueue()
true iff the queue is a min-queue
1.2public java.util.Iterator<E> iterator()
public boolean remove(java.lang.Object o)
remove in interface java.util.Collection<E>public boolean removeAll(java.util.Collection<?> c)
removeAll in interface java.util.Collection<E>public boolean retainAll(java.util.Collection<?> c)
retainAll in interface java.util.Collection<E>public void setPriority(E element, double priority)
element - the element to change the priority forpriority - the new priority of the elementpublic int size()
size in interface java.util.Collection<E>public java.lang.Object[] toArray()
toArray in interface java.util.Collection<E>public <T> T[] toArray(T[] a)
toArray in interface java.util.Collection<E>Copyright © 2018. All Rights Reserved.