Skip to content

Commit e006923

Browse files
committed
rotato
1 parent bb51ece commit e006923

File tree

1 file changed

+1
-56
lines changed

1 file changed

+1
-56
lines changed

rope.lisp

+1-56
Original file line numberDiff line numberDiff line change
@@ -101,26 +101,6 @@
101101
;; Balancing ;;
102102
;;-----------;;
103103

104-
;; Balance: -2
105-
;; Left Rotation
106-
;; a c
107-
;; / \ / \
108-
;; b c a e
109-
;; / \ / \ / \
110-
;; d e b d f g
111-
;; / \
112-
;; f g
113-
114-
;; Balance: 2
115-
;; Right Rotation
116-
;; a b
117-
;; / \ / \
118-
;; b c d a
119-
;; / \ / \ / \
120-
;; d e f g e c
121-
;; / \
122-
;; f g
123-
124104
(defgeneric balance-factor (rope)
125105
(:method ((rope leaf))
126106
0)
@@ -160,50 +140,15 @@
160140
(with-slots (left right) rope
161141
(let ((bf (balance-factor rope)))
162142
(cond ((< 0 bf)
163-
;; (balance-children)
164143
(if (minusp (balance-factor left))
165144
(rotate-left-right rope)
166145
(rotate-right rope)))
167146
((> 0 bf)
168-
;; (balance-children)
169147
(if (plusp (balance-factor right))
170148
(rotate-right-left rope)
171149
(rotate-left rope)))
172150
(t
173-
rope))))
174-
;; (with-slots (left right) rope
175-
;; (let ((left (if (zerop (balance-factor left))
176-
;; left
177-
;; (balance-rope left)))
178-
;; (right (if (zerop (balance-factor right))
179-
;; right
180-
;; (balance-rope right)))
181-
;; (rope (concat-rope* left right))
182-
;; (bf (balance-factor rope)))
183-
;; (format t "root: ~a, left: ~a, right: ~a~%"
184-
;; bf
185-
;; (balance-factor left)
186-
;; (balance-factor right)
187-
;; )
188-
;; (cond ((< 0 bf)
189-
;; (if (minusp (balance-factor left))
190-
;; (rotate-left-right rope)
191-
;; (rotate-right rope)))
192-
;; ((> 0 bf)
193-
;; (if (plusp (balance-factor right))
194-
;; (rotate-right-left rope)
195-
;; (rotate-left rope)))
196-
;; (t
197-
;; rope))))
198-
;; (with-slots (left right) rope
199-
;; (let* ((left (if (balance-direction left) (balance-rope left) left))
200-
;; (right (if (balance-direction right) (balance-rope right) right))
201-
;; (rope (concat-rope* left right))
202-
;; (balance (balance rope)))
203-
;; (cond ((< 1 balance) (rotate rope :right))
204-
;; ((> -1 balance) (rotate rope :left))
205-
;; (t rope))))
206-
))
151+
rope))))))
207152

208153
;;---------;;
209154
;; Rebuild ;;

0 commit comments

Comments
 (0)