|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.AbstractCollection | +--harpoon.Util.BinHeapPriorityQueue
BinHeapPriorityQueue
is an implementation of the
PriorityQueue
interface. It supports O(1) time
peekMax
and O(lg n) time insert
and
removeMax
operations, assuming that
ArrayList
is implemented in a reasonable manner. The
remove
operation is probably slow however.
Look into implementing a FibinocciHeap-based representation if
speed becomes an issue.
Constructor Summary | |
BinHeapPriorityQueue()
Creates a BinHeapPriorityQueue . |
Method Summary | |
void |
clear()
|
boolean |
contains(Object o)
This is slow. |
Object |
deleteMax()
Returns and removes the Object in
this with the highest priority. |
boolean |
equals(Object o)
|
int |
hashCode()
|
void |
insert(Object item,
int priority)
Inserts item into this, assigning it priority
priority . |
boolean |
isEmpty()
|
Iterator |
iterator()
Returns the elements of this in no specific
order. |
Object |
peekMax()
Returns the Object in this with the
highest priority. |
boolean |
remove(Object o)
This is slow. |
int |
size()
|
Methods inherited from class java.util.AbstractCollection |
add, addAll, containsAll, removeAll, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Collection |
add, addAll, containsAll, removeAll, retainAll, toArray, toArray |
Constructor Detail |
public BinHeapPriorityQueue()
BinHeapPriorityQueue
.
Method Detail |
public void insert(Object item, int priority)
MaxPriorityQueue
item
into this, assigning it priority
priority
.
insert
in interface MaxPriorityQueue
item
- Object
being insertedpriority
- Priority of item
public Object peekMax()
MaxPriorityQueue
Object
in this
with the
highest priority.
peekMax
in interface MaxPriorityQueue
public Object deleteMax()
MaxPriorityQueue
Object
in
this
with the highest priority.
deleteMax
in interface MaxPriorityQueue
public void clear()
clear
in interface Collection
clear
in class AbstractCollection
public boolean contains(Object o)
contains
in interface Collection
contains
in class AbstractCollection
public boolean equals(Object o)
equals
in interface Collection
equals
in class Object
public int hashCode()
hashCode
in interface Collection
hashCode
in class Object
public boolean isEmpty()
isEmpty
in interface Collection
isEmpty
in class AbstractCollection
public Iterator iterator()
this
in no specific
order.
Iterator
which
returns the elements of this
this
is not modified while
the returned Iterator
is in use.
iterator
in interface Collection
iterator
in class AbstractCollection
public boolean remove(Object o)
remove
in interface Collection
remove
in class AbstractCollection
public int size()
size
in interface Collection
size
in class AbstractCollection
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |