NextPrevUpTopContentsIndex

typed-aref

Function
Summary

Accesses a typed aref vector efficiently.

Package

system

Signature

typed-aref type vector byte-index => value

(setf typed-aref) value type vector byte-index => value

Arguments

type

A type specifier.

vector

A vector created by make-typed-aref-vector.

byte-index

A non-negative fixnum.

Values

value

An object of type type .

Description

The function typed-aref allows efficient access to a typed aref vector.

type must evaluate to one of: double-float , float , single-float , (unsigned-byte 32) , (signed-byte 32) , (unsigned-byte 16) , (signed-byte 16) , (unsigned-byte 8) or (signed-byte 8) .

vector must be an object returned by make-typed-aref-vector.

byte-index specifies the index in bytes from the start of the data in the vector. It must be a non-negative fixnum which is less than the byte-length argument passed to make-typed-aref-vector.

typed-aref and (setf typed-aref) will be inlined to code which is as efficient as possible when compiled with (optimize (safety 0)) and a constant type. As usual, you need to add (optimize (float 0)) to remove boxing for the float types.

Note: Efficient access to foreign arrays is also available. See fli:foreign-typed-aref in the LispWorks Foreign Language Interface User Guide and Reference Manual

Example
(defun double-float-typed-aref-incf (x y z)
  (declare (optimize (float 0) (safety 0)))
  (incf (sys:typed-aref 'double-float x y)
        (the double-float z))
  x)
See also

make-typed-aref-vector


LispWorks Reference Manual - 12 Mar 2008

NextPrevUpTopContentsIndex