FIND now returns the NODE-KEY rather than the passed ITEM-KEY.
authorRyan Pavlik <rpavlik@gmail.com>
Mon, 21 May 2012 14:35:34 +0000 (09:35 -0500)
committerRyan Pavlik <rpavlik@gmail.com>
Mon, 21 May 2012 14:35:34 +0000 (09:35 -0500)
This means attached data can be modified without doing an additional
search, if the specified item is not inserted due to an existing key.
Whether the new key or old key is used is already a function of the
second return value.

binary-trees.lisp

index bccc1b6..46351f7 100644 (file)
@@ -57,7 +57,7 @@
       (let ((node-key (funcall key (datum node))))
         (cond
           ((funcall test node-key item-key)
-           (return-from find-insertion-point (values node direction-stack item-key)))
+           (return-from find-insertion-point (values node direction-stack node-key)))
           ((funcall pred item-key node-key)
            (push (cons node 'left) direction-stack)
            (setf node (left node)))