diff options
Diffstat (limited to 'lib/BinHeap.cc')
-rw-r--r-- | lib/BinHeap.cc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/BinHeap.cc b/lib/BinHeap.cc index 89dd0be..45f77e6 100644 --- a/lib/BinHeap.cc +++ b/lib/BinHeap.cc @@ -23,7 +23,7 @@ void BinHeap::PackUp(int i) { int l = LEFT(i), r = RIGHT(i), min; binheap_t *binheap = (binheap_t *) Datas; - + min = ((l <= Key) && (binheap[l - 1].Key < binheap[i - 1].Key)) ? l : i; if ((r <= Key) && (binheap[r - 1].Key < binheap[min - 1].Key)) min = r; @@ -51,10 +51,11 @@ PriorityList *BinHeap::Union(PriorityList * P) bool BinHeap::Lower_Key(Cell x, Key_t NKey) { - int i = ((binheap_t *)x) - ((binheap_t*)Datas) + 1; - binheap_t * binheap = (binheap_t*) Datas; + int i = ((binheap_t *) x) - ((binheap_t *) Datas) + 1; + binheap_t *binheap = (binheap_t *) Datas; - if (((binheap_t*)x)->Key < NKey) return false; + if (((binheap_t *) x)->Key < NKey) + return false; while ((i > 1) && (binheap[FATHER(i) - 1].Key > NKey)) { SWAP(binheap[i - 1], binheap[FATHER(i) - 1]); i = FATHER(i); @@ -124,7 +125,7 @@ Cell BinHeap::Insert(Key_t IKey, Datas_t const &IDatas) i = Key; binheap = (binheap_t *) Datas; - + while ((i > 1) && (binheap[FATHER(i) - 1].Key > IKey)) { binheap[i - 1] = binheap[FATHER(i) - 1]; i = FATHER(i); |