|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--xxl.collections.AbstractQueue
|
+--xxl.collections.Heap
The heap datastructure.
| Field Summary | |
protected java.lang.Object[] |
array
The array used for the internal representation of the data. |
protected java.util.Comparator |
comparator
The Comparator used to compare elements in the heap. |
static Function |
FACTORY_METHOD
A factory method to create a new Heap. |
protected int |
last
The last element in the heap. |
| Fields inherited from class xxl.collections.AbstractQueue |
FACTORY_METHOD |
| Constructor Summary | |
Heap(int size)
Creates an empty Heap. |
|
Heap(int size,
java.util.Comparator comparator)
Creates an empty Heap. |
|
Heap(java.lang.Object[] array)
Creates a Heap for a given Array in O(n) time. |
|
Heap(java.lang.Object[] array,
java.util.Comparator comparator)
Creates a Heap for a given Array in O(n) time. |
|
Heap(java.lang.Object[] array,
int size)
Creates a Heap for a given Array in O(n) time. |
|
Heap(java.lang.Object[] array,
int size,
java.util.Comparator comparator)
Creates a Heap for a given Array in O(n) time. |
|
| Method Summary | |
protected void |
bubbleUp(java.lang.Object object,
int i)
|
void |
clear()
Removes all elements from the heap. |
protected void |
heapify()
Computes the heap for a given Array in O(n) time. |
void |
insert(java.lang.Object object)
Inserts an Object into the heap. |
void |
insertAll(java.util.Iterator objects)
Inserts all elements of a given Iterator into the heap. |
java.lang.Object |
next()
Returns the next element in the iteration. |
java.lang.Object |
peek()
Shows the next element in the iteration without removing it. |
java.lang.Object |
replace(java.lang.Object object)
Inserts a given object and returns this.next(). |
protected int |
sinkIn(int i)
|
int |
size()
Returns the size of the heap. |
boolean |
supportsPeek()
Returns true if the peek operation is supported by this PeekIterator. |
| Methods inherited from class xxl.collections.AbstractQueue |
close,
hasNext,
remove,
replaceAll |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
public static final Function FACTORY_METHOD
protected java.lang.Object[] array
protected int last
protected java.util.Comparator comparator
| Constructor Detail |
public Heap(java.lang.Object[] array,
int size,
java.util.Comparator comparator)
array - the array for which the heap is to be createdsize - the size of the heapthe - Comparator used to compare elements in the heappublic Heap(java.lang.Object[] array)
array - the array for which the heap is to be created
public Heap(java.lang.Object[] array,
int size)
array - the array for which the heap is to be createdsize - the size of the heap
public Heap(java.lang.Object[] array,
java.util.Comparator comparator)
array - the array for which the heap is to be createdthe - Comparator used to compare elements in the heap
public Heap(int size,
java.util.Comparator comparator)
size - the maximum size of the heapthe - Comparator used to compare elements in the heappublic Heap(int size)
size - the maximum size of the heap| Method Detail |
protected void heapify()
protected void bubbleUp(java.lang.Object object,
int i)
protected int sinkIn(int i)
public void clear()
public int size()
public void insert(java.lang.Object object)
public void insertAll(java.util.Iterator objects)
objects - an Iterator of Objects
public java.lang.Object peek()
throws java.util.NoSuchElementException
public java.lang.Object next()
throws java.util.NoSuchElementException
public java.lang.Object replace(java.lang.Object object)
throws java.util.NoSuchElementException
this.next().public boolean supportsPeek()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||