[funds-cvs] r90 - trunk/funds/src/trees

abaine at common-lisp.net abaine at common-lisp.net
Wed Jul 11 20:51:03 UTC 2007


Author: abaine
Date: Wed Jul 11 16:51:03 2007
New Revision: 90

Modified:
   trunk/funds/src/trees/tree-remove.lisp
Log:
Fixed problem where heavier-p was being passed an empty tree.

Modified: trunk/funds/src/trees/tree-remove.lisp
==============================================================================
--- trunk/funds/src/trees/tree-remove.lisp	(original)
+++ trunk/funds/src/trees/tree-remove.lisp	Wed Jul 11 16:51:03 2007
@@ -37,13 +37,15 @@
 
 (defmethod tree-remove ((tree avl-tree) key &key (test #'eql) (order #'<))
   (declare (ignore test order))
-  (let* ((temp (call-next-method))
-	 (heavy-side (if (heavier-p temp :side :left)
-			 :left
-			 :right))
-	 (inside (tree-child temp :side (other-side heavy-side)))
-	 (outside (tree-child temp :side heavy-side)))
-    (balance inside temp outside :heavy-side heavy-side)))
+  (let ((temp (call-next-method)))
+    (if (tree-empty-p temp)
+	(make-avl-tree)
+	(let* ((heavy-side (if (heavier-p temp :side :left)
+			      :left
+			      :right))
+	       (inside (tree-child temp :side (other-side heavy-side)))
+	       (outside (tree-child temp :side heavy-side)))
+	  (balance inside temp outside :heavy-side heavy-side)))))
 
 
 (defmethod remove-root ((tree binary-tree) &key test order)



More information about the Funds-cvs mailing list