Add functions to manipulate fill-pointer of arrays
This commit is contained in:
parent
c8af805cbe
commit
3915cdcba1
1 changed files with 14 additions and 0 deletions
|
|
@ -12,6 +12,7 @@
|
|||
#:add-hook #:remove-hook #:run-hook
|
||||
#:node #:parent #:children #:attach-node #:detach-node
|
||||
#:shared-object #:refcount #:inc-ref #:dec-ref
|
||||
#:extend-array #:shrink-array
|
||||
#:error-implementation-unsupported
|
||||
#:get-command-line-option
|
||||
#:get-command-line-option-number
|
||||
|
|
@ -122,6 +123,19 @@
|
|||
(when (> refcount 0)
|
||||
(decf refcount))))
|
||||
|
||||
(let ((extend-ratio 1.5))
|
||||
(defun extend-array (array)
|
||||
"Extend an array to extend-ratio coefficient."
|
||||
(when (= (fill-pointer array) (array-total-size array))
|
||||
(adjust-array array (floor (* (array-total-size array) extend-ratio))))
|
||||
(prog1
|
||||
(fill-pointer array)
|
||||
(incf (fill-pointer array))))
|
||||
|
||||
(defun shrink-array (array new-fill-pointer)
|
||||
"Shrink an array to its fill-pointer."
|
||||
(setf (fill-pointer array) new-fill-pointer)))
|
||||
|
||||
(defun error-implementation-unsupported ()
|
||||
"Return an error specifying the current lisp implementation is not supported."
|
||||
(error "For now, only sbcl is supported."))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue