Handbook
Glossary
tree
Vocabulary
trees
Class description
This is the class for unbalanced binary search trees. It is not usually intended to be used directly but rather as a basis for other trees.
Definition
USING:
math
;
IN:
trees
TUPLE:
tree
root
{
count
integer
initial:
0
}
;
Methods
USING:
accessors
assocs
make
trees
trees.private
;
M:
tree
>alist
[
root>>
(node>alist)
]
{
}
make
;
USING:
assocs
prettyprint.custom
trees
;
M:
tree
>pprint-sequence
>alist
;
USING:
assocs
generic
kernel
trees
trees.private
;
M:
tree
assoc-clone-like
[
dup
tree?
[
>bfs-alist
]
when
]
dip
M\
tree
assoc-clone-like
(call-next-method)
;
USING:
assocs
kernel
trees
;
M:
tree
assoc-like
drop
dup
tree?
[
>tree
]
unless
;
USING:
accessors
assocs
trees
;
M:
tree
assoc-size
count>>
;
USING:
accessors
assocs
trees
trees.private
;
M:
tree
at*
root>>
node-at*
;
USING:
accessors
assocs
kernel
trees
;
M:
tree
clear-assoc
0
>>count
f
>>root
drop
;
USING:
accessors
kernel
trees
trees.private
;
M:
tree
clone
(clone)
[
clone-nodes
]
change-root
;
USING:
accessors
assocs
kernel
trees
trees.private
;
M:
tree
delete-at
[
delete-bst-node
swap
]
change-root
swap
[
dup
dec-count
]
when
drop
;
USING:
assocs
kernel
trees
;
M:
tree
new-assoc
2drop
<tree>
;
USING:
kernel
prettyprint.custom
trees
;
M:
tree
pprint-delims
drop
\
TREE{
\
}
;
USING:
kernel
prettyprint.custom
trees
;
M:
tree
pprint-narrow?
drop
t
;
USING:
accessors
assocs
kernel
trees
trees.private
;
M:
tree
set-at
[
[
node-set
]
[
swap
<node>
t
]
if*
swap
]
change-root
swap
[
dup
inc-count
]
when
drop
;