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

abaine at common-lisp.net abaine at common-lisp.net
Wed Jul 4 17:39:42 UTC 2007


Author: abaine
Date: Wed Jul  4 13:39:42 2007
New Revision: 49

Modified:
   trunk/funds/src/trees/avl-tree.lisp
Log:
avl-remove method added.

Modified: trunk/funds/src/trees/avl-tree.lisp
==============================================================================
--- trunk/funds/src/trees/avl-tree.lisp	(original)
+++ trunk/funds/src/trees/avl-tree.lisp	Wed Jul  4 13:39:42 2007
@@ -33,6 +33,14 @@
 	(t (side-insert tree key value test order 
 			:side (if (funcall order key (avl-key tree)) :left :right)))))
 
+(defun avl-remove (tree key &key (test #'eql) (order #'<))
+  "The AVL Tree that results when the given key and its associated value are
+removed from the given tree."
+  (cond ((avl-empty-p tree) tree)
+	((funcall test key (avl-key tree)) ())
+	(t (side-remove tree key test order 
+			:side (if (funcall order key (avl-key tree)) :left :right)))))
+
 (defun avl-find-value (tree key &key (order #'<) (test #'eql))
   "The value associated with the given key in the given AVL Tree.  The function
 returns nil if the key is not found in the given tree; a second value is returned



More information about the Funds-cvs mailing list