Add a method to get to the root of a node tree
This commit is contained in:
parent
8838362c26
commit
dfe1b3940c
1 changed files with 7 additions and 1 deletions
|
|
@ -10,7 +10,7 @@
|
|||
#:progress-step
|
||||
#:loop-with-progress
|
||||
#:add-hook #:remove-hook #:run-hook
|
||||
#:node #:parent #:children #:attach-node #:detach-node
|
||||
#:node #:parent #:children #:attach-node #:detach-node #:root
|
||||
#:shared-object #:refcount #:inc-ref #:dec-ref
|
||||
#:extend-array #:shrink-array
|
||||
#:error-implementation-unsupported
|
||||
|
|
@ -106,6 +106,12 @@
|
|||
(setf children (delete node children)))))
|
||||
node)
|
||||
|
||||
(defgeneric root (node))
|
||||
(defmethod root ((node node))
|
||||
(if (parent node)
|
||||
(root (parent node))
|
||||
node))
|
||||
|
||||
(defmethod initialize-instance :after ((node node) &key parent)
|
||||
(attach-node node parent))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue