E
- element type.public class PriorityQueue<E> extends AbstractQueue<E>
Constructor and Description |
---|
PriorityQueue() |
PriorityQueue(Collection<? extends E> c) |
PriorityQueue(int initialCapacity) |
PriorityQueue(int initialCapacity,
Comparator<? super E> cmp) |
PriorityQueue(PriorityQueue<? extends E> c) |
PriorityQueue(SortedSet<? extends E> c) |
Modifier and Type | Method and Description |
---|---|
boolean |
addAll(Collection<? extends E> c) |
void |
clear() |
Comparator<? super E> |
comparator() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
protected void |
makeHeap(int node)
Make the subtree rooted at
node a valid heap. |
protected void |
mergeHeaps(int node)
Merge two subheaps into a single heap.
|
boolean |
offer(E e) |
E |
peek() |
E |
poll() |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
String |
toString() |
add, element, remove
equals, hashCode
public PriorityQueue()
public PriorityQueue(Collection<? extends E> c)
public PriorityQueue(int initialCapacity)
public PriorityQueue(int initialCapacity, Comparator<? super E> cmp)
public PriorityQueue(PriorityQueue<? extends E> c)
public boolean addAll(Collection<? extends E> c)
addAll
in interface Collection<E>
addAll
in class AbstractQueue<E>
public void clear()
clear
in interface Collection<E>
clear
in class AbstractQueue<E>
public Comparator<? super E> comparator()
public boolean contains(Object o)
contains
in interface Collection<E>
contains
in class AbstractCollection<E>
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<E>
containsAll
in class AbstractCollection<E>
public boolean isEmpty()
isEmpty
in interface Collection<E>
isEmpty
in class AbstractCollection<E>
public Iterator<E> iterator()
iterator
in interface Iterable<E>
iterator
in interface Collection<E>
iterator
in class AbstractCollection<E>
public boolean offer(E e)
public E peek()
public E poll()
public boolean remove(Object o)
remove
in interface Collection<E>
remove
in class AbstractCollection<E>
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<E>
removeAll
in class AbstractCollection<E>
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<E>
retainAll
in class AbstractCollection<E>
public int size()
size
in interface Collection<E>
size
in class AbstractCollection<E>
public Object[] toArray()
toArray
in interface Collection<E>
toArray
in class AbstractCollection<E>
public <T> T[] toArray(T[] a)
toArray
in interface Collection<E>
toArray
in class AbstractCollection<E>
public String toString()
toString
in class AbstractCollection<E>
protected void makeHeap(int node)
node
a valid heap. O(n) timenode
- protected void mergeHeaps(int node)
node
are heapsnode
- the parent of the two subtrees to mergeCopyright © 2018. All rights reserved.