net.groboclown.gui.tripleBuffer.v1.test
Class Heap

java.lang.Object
  |
  +--net.groboclown.gui.tripleBuffer.v1.test.Heap

public class Heap
extends Object

Used for storing drawing elements, such as polygons and bitmaps, and sorting them according to a key. Need to make this efficient, especially for the polygons (the polygons will probably just store a Long whose value is (y * MAP_Y) + x). Fibonacci heap could be used to merge the two heaps together, but they are too complex and require too much memory for our purposes. Since we only have two heaps, it would be trivial to do a "on-the-fly" merge. Keys are doubles, values are Objects Uses an Array to store the values for efficiency, though we simulate a Vector. We keep the array filled with HeapElements; those past


Field Summary
(package private)  int currentSize
           
static int DEFAULT_INCREMENT_SIZE
           
static int DEFAULT_SIZE
           
(package private)  HeapElement[] heap
           
(package private)  int incSize
           
(package private)  boolean notDoneHeapify
           
(package private)  int size
           
 
Constructor Summary
Heap()
           
Heap(int initSize)
           
Heap(int initSize, int incrementSize)
           
 
Method Summary
 void add(double key, Object val)
           
 void addSet(double[] keys, Object[] vals, int num)
           
 void clear()
          Cleans out all heap[i].value to eliminate memory leaks, then sets the currentSize to 0.
protected  void finalize()
           
 int getCapacity()
           
 Object getNext()
           
protected  void heapify(int i)
           
protected  void increaseArray()
           
 int length()
           
static void main(String[] args)
           
 double peekNextKey()
           
 Object peekNextValue()
           
 void sort()
           
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

DEFAULT_SIZE

public static final int DEFAULT_SIZE

DEFAULT_INCREMENT_SIZE

public static final int DEFAULT_INCREMENT_SIZE

heap

HeapElement[] heap

size

int size

incSize

int incSize

currentSize

int currentSize

notDoneHeapify

boolean notDoneHeapify
Constructor Detail

Heap

public Heap()

Heap

public Heap(int initSize)

Heap

public Heap(int initSize,
            int incrementSize)
Method Detail

main

public static void main(String[] args)

clear

public void clear()
Cleans out all heap[i].value to eliminate memory leaks, then sets the currentSize to 0.

add

public void add(double key,
                Object val)

addSet

public void addSet(double[] keys,
                   Object[] vals,
                   int num)

length

public int length()

getCapacity

public int getCapacity()

peekNextKey

public double peekNextKey()

peekNextValue

public Object peekNextValue()

getNext

public Object getNext()

sort

public void sort()

heapify

protected void heapify(int i)

increaseArray

protected void increaseArray()

finalize

protected void finalize()
Overrides:
finalize in class Object


Written under the LGPL