private void swap(int a, int b) { HeapNode temp = new HeapNode(); temp = mHeap[a]; mHeap[a] = mHeap[b]; mHeap[b] = temp; }
public HeapNode pop() { HeapNode result = mHeap[0]; swap(0, heapSize); heapSize--; downheap(0); return(result); }
public void init() { for (int i = 1; i <= n; i++) { if(i!=s) { HeapNode node = new HeapNode(i, Max); mheap.add(node); } } HeapNode nodeS = new HeapNode(s, 0); mheap.add(nodeS); for (int i = 1; i <= n; i++) free[i] = true; }
public void add(HeapNode node) { mHeap.Add(node); upheap(heapSize); heapSize++; }