6 ;;; Structures give better performance than CLOS.
10 (:constructor make-tree-node (datum))
12 (left nil :type (or null tree-node))
13 (right nil :type (or null tree-node))
17 (defstruct (avl-tree-node
19 (:constructor make-avl-node (datum))
22 (balance-info 0 :type (integer -2 2)))
24 (defconstant +avl-equal+ 0)
25 (defconstant +avl-leans-left+ -1)
26 (defconstant +avl-leans-right+ +1)
27 (defconstant +avl-falls-left+ -2)
28 (defconstant +avl-falls-right+ +2)
30 (deftype red-black-color ()
31 "Keywords denoting red-black tree colors."
32 '(member :red :black))
34 (defstruct (red-black-tree-node
36 (:constructor make-red-black-node (datum))
39 (color :red :type red-black-color))
41 (defstruct (aa-tree-node
43 (:constructor make-aa-node (datum))
46 (level 1 :type fixnum))
50 (defstruct (binary-tree
52 (:constructor %make-binary-tree (pred key test
57 (test #1=(error "missing arg") :type function :read-only t)
58 (key #1# :type function :read-only t)
59 (pred #1# :type function :read-only t)
61 (root nil :type (or null tree-node))
62 (modcount 0 :type fixnum)
63 (nodegen #1# :type function :read-only t)
64 (rebalance/insert nil :type (or null function) :read-only t)
65 (rebalance/delete nil :type (or null function) :read-only t))