summaryrefslogtreecommitdiff
path: root/lib/FHeap.cc
diff options
context:
space:
mode:
authorPixel <>2001-03-07 00:41:50 +0000
committerPixel <>2001-03-07 00:41:50 +0000
commit3aff7aaa9de61a5f3430bd86960c4f9c4b958786 (patch)
treee4f83c05031ccd816a2e8e8b3bf8d9a857484fbd /lib/FHeap.cc
parentcd61178eb1d3b9182f4fcb64cc8eee61971405a8 (diff)
Version finale pour les algos.
Diffstat (limited to 'lib/FHeap.cc')
-rw-r--r--lib/FHeap.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/FHeap.cc b/lib/FHeap.cc
index 158a1e5..a10e089 100644
--- a/lib/FHeap.cc
+++ b/lib/FHeap.cc
@@ -58,13 +58,17 @@ void FHeap::Rebuild(void)
w = x->Left;
SWAP(x, y);
}
+ if (y == Child) {
+ Child = x;
+ }
y->Link(x);
A[d++] = NULL;
}
A[d] = x;
/* Nous recalculons l'éventuelle nouvelle valeur de max[T]. */
- if (ReadKey(Child) > ReadKey(w))
+ if (ReadKey(Child) > ReadKey(w)) {
Child = w;
+ }
}
/* Contrairement au Cormen, nous n'avons pas besoin de reconstruire ici
@@ -299,8 +303,8 @@ void FHeap::Cut(FHeap * x, FHeap * y)
y->Degree--;
- x->Right->Left = Left;
- x->Left->Right = Right;
+ x->Right->Left = x->Left;
+ x->Left->Right = x->Right;
if (y->Child == x) {
y->Child = y->Degree ? x->Right : NULL;