From 3aff7aaa9de61a5f3430bd86960c4f9c4b958786 Mon Sep 17 00:00:00 2001 From: Pixel <> Date: Wed, 7 Mar 2001 00:41:50 +0000 Subject: Version finale pour les algos. --- lib/FHeap.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/FHeap.cc') 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; -- cgit v1.2.3