|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.siebengeisslein.util.LongHeap
public class LongHeap
This class implements a heap that contains Comparables. It is base on an implementation from Robert Sedgewicks book "Algorithms". It has to be assured, when using the heap, that the comparTo() method of all objects are compatible and do not throw a ClassNotFoundException, when compared to aach other. In a heap is it possible to add elemnts to this heap, and to remove the first element (which is bigger than all other elements). This implementation provides guaranteed log(n) time cost for both operations.
| Constructor Summary | |
|---|---|
LongHeap()
Creates a new heap with a default size. |
|
LongHeap(int initialSize)
Creates a new heap with a given initial size. |
|
| Method Summary | |
|---|---|
void |
add(long value)
Add a new entry to the heap. |
java.lang.Object |
clone()
|
boolean |
contains(long value)
|
boolean |
isEmpty()
Return wether this heap is empty. |
void |
read(java.io.RandomAccessFile file)
|
long |
removeFirst()
Returns the biggest entry of the heap and removes it. |
int |
size()
Return the size of the heap. |
void |
write(java.io.RandomAccessFile file)
|
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LongHeap()
public LongHeap(int initialSize)
initialSize - Initial size of the heap (>0)| Method Detail |
|---|
public boolean contains(long value)
public void add(long value)
obj - New Entry. This has to be comparable to all other entries
in the heap and may not be null.public long removeFirst()
public int size()
public boolean isEmpty()
public void write(java.io.RandomAccessFile file)
throws java.io.IOException
java.io.IOException
public void read(java.io.RandomAccessFile file)
throws java.io.IOException
java.io.IOExceptionpublic java.lang.Object clone()
clone in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||