|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmaspack.util.BinaryHeap<E>
E
- public class BinaryHeap<E>
PriorityQueue
.
This exposes the update
function which can re-order the queue if any
internal values are updated.Nested Class Summary | |
---|---|
static class |
BinaryHeap.DefaultComparator<E>
|
Field Summary | |
---|---|
static int |
DEFAULT_CAPACITY
|
static boolean |
DEFAULT_MIN_HEAP
|
Constructor Summary | |
---|---|
BinaryHeap()
Creates a minimum BinaryHeap with with default initial capacity
and natural ordering comparator |
|
BinaryHeap(java.util.Comparator<E> c)
Creates a minimum BinaryHeap that uses the supplied comparator
to order values |
|
BinaryHeap(int capacity)
Creates a minimum BinaryHeap with with supplied initial capacity
and natural ordering |
|
BinaryHeap(int capacity,
java.util.Comparator<E> c,
boolean min)
Creates a BinaryHeap according to the supplied parameters |
Method Summary | ||
---|---|---|
boolean |
add(E e)
Inserts an element into the Binary Heap |
|
boolean |
addAll(java.util.Collection<? extends E> c)
|
|
void |
clear()
|
|
java.util.Comparator<E> |
comparator()
Returns the comparator used to order elements |
|
boolean |
contains(java.lang.Object o)
|
|
boolean |
containsAll(java.util.Collection<?> c)
|
|
void |
ensureCapacity(int capacity)
Ensures the heap's capacity is at least the supplied value |
|
boolean |
isEmpty()
|
|
boolean |
isMaxHeap()
Returns true if this is a max-heap |
|
boolean |
isMinHeap()
Returns true if this is a min-heap |
|
java.util.Iterator<E> |
iterator()
|
|
boolean |
offer(E e)
Inserts an element into the Binary Heap |
|
E |
peek()
Looks at the top element in the heap, without removing it |
|
E |
peekLast()
|
|
E |
poll()
Retrieves and removes the top element in the heap |
|
E |
pollLast()
|
|
boolean |
remove(java.lang.Object o)
|
|
boolean |
removeAll(java.util.Collection<?> c)
|
|
boolean |
retainAll(java.util.Collection<?> c)
|
|
void |
set(java.util.Collection<E> vals)
|
|
void |
set(E[] vals)
Initializes a heap from an array |
|
int |
size()
|
|
java.lang.Object[] |
toArray()
|
|
|
toArray(T[] a)
|
|
void |
update()
Re-orders the heap. |
|
void |
update(E val)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Collection |
---|
equals, hashCode |
Field Detail |
---|
public static final int DEFAULT_CAPACITY
public static final boolean DEFAULT_MIN_HEAP
Constructor Detail |
---|
public BinaryHeap()
BinaryHeap
with with default initial capacity
and natural ordering comparator
public BinaryHeap(int capacity)
BinaryHeap
with with supplied initial capacity
and natural ordering
capacity
- initial capacitypublic BinaryHeap(java.util.Comparator<E> c)
BinaryHeap
that uses the supplied comparator
to order values
public BinaryHeap(int capacity, java.util.Comparator<E> c, boolean min)
BinaryHeap
according to the supplied parameters
capacity
- initial capacityc
- Comparator
to use to compare elementsmin
- if true, creates a min-heap, otherwise creates a max-heapMethod Detail |
---|
public java.util.Comparator<E> comparator()
public int size()
size
in interface java.util.Collection<E>
public boolean isEmpty()
isEmpty
in interface java.util.Collection<E>
public boolean contains(java.lang.Object o)
contains
in interface java.util.Collection<E>
public java.util.Iterator<E> iterator()
iterator
in interface java.lang.Iterable<E>
iterator
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>
public boolean offer(E e)
public boolean add(E e)
add
in interface java.util.Collection<E>
public E peek()
public E poll()
public boolean remove(java.lang.Object o)
remove
in interface java.util.Collection<E>
public E peekLast()
public E pollLast()
public boolean containsAll(java.util.Collection<?> c)
containsAll
in interface java.util.Collection<E>
public boolean addAll(java.util.Collection<? extends E> c)
addAll
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 clear()
clear
in interface java.util.Collection<E>
public boolean isMinHeap()
public boolean isMaxHeap()
public void ensureCapacity(int capacity)
public void update()
public void set(E[] vals)
public void set(java.util.Collection<E> vals)
public void update(E val)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |