|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjist.runtime.Scheduler
jist.runtime.Scheduler.Heap
static final class Scheduler.Heap
Implements an array-based heap of Events. In addition to the regular heap functionality, there are methods for extracting elements other than the min.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class jist.runtime.Scheduler |
|---|
Scheduler.Calendar, Scheduler.Heap |
| Field Summary | |
|---|---|
private int |
halveSize
Collapse size. |
static int |
INIT_LENGTH
Initial size of internal heap array. |
private Event[] |
items
Internal array of heap items. |
private int |
size
Number of elements in heap. |
| Constructor Summary | |
|---|---|
Scheduler.Heap()
Create a new, empty heap with given comparator. |
|
| Method Summary | |
|---|---|
private void |
doubleCapacity()
Double the capacity of the internal array. |
private void |
halveCapacity()
Halve the capacity of the internal array. |
private void |
heapify(int i)
Establish heap order in internal array from given index. |
void |
insert(Event ev)
Insert event into event queue. |
boolean |
isEmpty()
Return whether event queue is empty. |
private int |
left(int i)
Find left child location in heap-ordered array. |
private int |
parent(int i)
Find parent location in heap-ordered array. |
Event |
peekFirst()
Peek at first event in queue. |
Event |
removeFirst()
Remove first event in queue. |
Event |
removeIndex(int i)
Return the element stored a given location in the internal heap array and remove it from the heap. |
private int |
right(int i)
Find right child location in heap-ordered array. |
int |
size()
Return size of event queue. |
private void |
swap(int i,
int j)
Swap data in two array locations. |
| Methods inherited from class jist.runtime.Scheduler |
|---|
clear, main |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int INIT_LENGTH
private Event[] items
private int size
private int halveSize
| Constructor Detail |
|---|
public Scheduler.Heap()
| Method Detail |
|---|
private int parent(int i)
i - location to find parent of
private int left(int i)
i - location to find left child of
private int right(int i)
i - location to find right child of
private void swap(int i,
int j)
i - first locationj - second locationpublic void insert(Event ev)
insert in class Schedulerev - event to insertpublic int size()
size in class Schedulerpublic boolean isEmpty()
isEmpty in class Schedulerpublic Event peekFirst()
peekFirst in class Schedulerpublic Event removeFirst()
removeFirst in class Schedulerpublic Event removeIndex(int i)
i - index into the internal heap array
private void heapify(int i)
i - index into internal heap arrayprivate void doubleCapacity()
private void halveCapacity()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||