Lots of tidying up.
[lisp] / aa-tree.lisp
index 6c42746..a08d52d 100644 (file)
@@ -1,7 +1,5 @@
 ;;; -*-lisp-*-
 ;;;
-;;; $Id$
-;;;
 ;;; Andersson tree implementation
 ;;;
 ;;; (c) 2006 Straylight/Edgeware
@@ -27,9 +25,7 @@
 ;;; Package.
 
 (defpackage #:aa-tree
-  (:use #:common-lisp #:mdw.base)
-  (:export #:make-aa-tree #:aa-tree-p #:aa-tree-key<
-          #:getaa #:updateaa #:mapaa #:doaa #:aa-tree-iterator #:remaa))
+  (:use #:common-lisp #:mdw.base))
 (in-package #:aa-tree)
 
 ;;;--------------------------------------------------------------------------
@@ -51,6 +47,7 @@
 
 (deftype tree-node () 'simple-vector)
 
+(export '(make-aa-tree aa-tree aa-tree-p aa-tree-key<))
 (defstruct (aa-tree
             (:predicate treep)
             (:constructor make-aa-tree
        (do ((need (ash size 1) (ash need 1)))
            ((>= need want) (setf (tree-stack tree) (make-array need)))))))
 
+(export 'getaa)
 (defun getaa (tree key &optional default)
   "Look up the given KEY in an Andersson TREE; if the KEY was found, return
    the corresponding data and t, otherwise return DEFAULT and nil."
     (cond (node (setf (node-data node) data))
          (t (fixup-insert tree stack sp (make-tree-node key data)) data))))
 
+(export 'updateaa)
 (defun updateaa (tree key func)
   "Search TREE for an item with the given KEY.  If it was found, call FUNC
    with arguments of the node's data and t, and store its result as the
               (fixup-insert tree stack sp (make-tree-node key data))
               data)))))
 
+(export 'remaa)
 (defun remaa (tree key)
   "Deletes the node with the given KEY from an Andersson TREE.  Returns t if
    the node was found and deleted, or nil if it wasn't there to begin with."
        ;; Store the new root.
        (setf (tree-root tree) node)))))
 
+(export 'aa-tree-iterator)
 (defun aa-tree-iterator (tree)
   "Returns a tree iterator function for TREE.  The function returns three
    values.  For each node in the tree, it returns t, the key and the value;
                         (pushleft (node-right node))
                         (values t (node-key node) (node-data node)))))))))))
 
+(export 'mapaa)
 (defun mapaa (func tree)
   "Apply FUNC to each key and value in the TREE."
   (labels ((walk (node)
     (walk (tree-root tree))
     nil))
 
+(export 'doaa)
 (defmacro doaa ((key value tree &optional result) &body body)
   "Iterate over the items of TREE; for each one, bind KEY to its key and
    VALUE to the associated data, and evaluate BODY, which is an implicit