/[flexichain]/flexichain/flexichain.lisp
ViewVC logotype

Diff of /flexichain/flexichain.lisp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by charmon, Fri Jan 25 23:59:21 2008 UTC revision 1.5 by rstrandh, Sat Jan 26 11:23:09 2008 UTC
# Line 297  element of the CHAIN." Line 297  element of the CHAIN."
297    
298  (defmethod delete-elements* ((chain standard-flexichain) position n)  (defmethod delete-elements* ((chain standard-flexichain) position n)
299    (unless (zerop n)    (unless (zerop n)
300      (with-slots (buffer expand-factor min-size fill-element gap-end gap-start) chain      (with-slots (buffer expand-factor min-size gap-end data-start) chain
301        (when (minusp n)        (when (minusp n)
302          (incf position n)          (incf position n)
303          (setf n (* -1 n)))          (setf n (* -1 n)))
304        (assert (<= 0 (+ position n) (nb-elements chain)) ()        (assert (<= 0 (+ position n) (nb-elements chain)) ()
305                'flexi-position-error :chain chain :position position)                'flexi-position-error :chain chain :position position)
306        (ensure-gap-position chain position)        (ensure-gap-position chain position)
307        (fill-gap chain gap-end (+ gap-end n))        ;; Two cases to consider - one where position+n is wholly on
308        (incf gap-end n)        ;; this side of the gap in buffer, and one where part of it is
309          ;; "wrapped around" to the beginning of buffer.
310          (cond ((>= (length buffer) (+ gap-end n))
311                 (fill-gap chain gap-end (+ gap-end n))
312                 (incf gap-end n))
313                (t (let ((surplus-elements (- n (- (length buffer) gap-end))))
314                     (fill-gap chain gap-end (length buffer))
315                     (fill-gap chain 0 surplus-elements)
316                     (setf gap-end surplus-elements
317                           data-start (1+ gap-end)))))
318        (when (= gap-end (length buffer))        (when (= gap-end (length buffer))
319          (setf gap-end 0))          (setf gap-end 0))
320        (when (and (> (length buffer) (+ min-size 2))        (when (and (> (length buffer) (+ min-size 2))

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.5