5.1 Safe Homogenous Vectors
(require ffi/vector) |
Homogenous vectors are similar to C vectors (see Safe C Vectors), except that they define different types of vectors, each with a hard-wired type. An exception is the u8 family of bindings, which are just aliases for byte-string bindings; for example, make-u8vector is an alias for make-bytes.
(make-u8vector len) → u8vector? len : exact-nonnegative-integer? (u8vector val ...) → u8vector? val : number? (u8vector? v) → boolean? v : any/c (u8vector-length vec) → exact-nonnegative-integer? vec : u8vector? (u8vector-ref vec k) → number? vec : u8vector? k : exact-nonnegative-integer? (u8vector-set! vec k val) → void? vec : u8vector? k : exact-nonnegative-integer? val : number? (list->u8vector lst) → u8vector? lst : (listof number?) (u8vector->list vec) → (listof number?) vec : u8vector? (u8vector->cpointer vec) → cpointer? vec : u8vector?
Like _cvector, but for vectors of _byte elements. These are
aliases for byte operations, where u8vector->cpointer
is the identity function.
(make-s8vector len) → s8vector? len : exact-nonnegative-integer? (s8vector val ...) → s8vector? val : number? (s8vector? v) → boolean? v : any/c (s8vector-length vec) → exact-nonnegative-integer? vec : s8vector? (s8vector-ref vec k) → number? vec : s8vector? k : exact-nonnegative-integer? (s8vector-set! vec k val) → void? vec : s8vector? k : exact-nonnegative-integer? val : number? (list->s8vector lst) → s8vector? lst : (listof number?) (s8vector->list vec) → (listof number?) vec : s8vector? (s8vector->cpointer vec) → cpointer? vec : s8vector?
Like make-vector, etc., but for _int8 elements. The s8vector->cpointer function extracts a plain pointer to the underlying array.
(make-s16vector len) → s16vector? len : exact-nonnegative-integer? (s16vector val ...) → s16vector? val : number? (s16vector? v) → boolean? v : any/c (s16vector-length vec) → exact-nonnegative-integer? vec : s16vector? (s16vector-ref vec k) → number? vec : s16vector? k : exact-nonnegative-integer? (s16vector-set! vec k val) → void? vec : s16vector? k : exact-nonnegative-integer? val : number? (list->s16vector lst) → s16vector? lst : (listof number?) (s16vector->list vec) → (listof number?) vec : s16vector? (s16vector->cpointer vec) → cpointer? vec : s16vector?
Like make-vector, etc., but for _int16 elements. The s16vector->cpointer function extracts a plain pointer to the underlying array.
(_s16vector mode maybe-len) _s16vector
(make-u16vector len) → u16vector? len : exact-nonnegative-integer? (u16vector val ...) → u16vector? val : number? (u16vector? v) → boolean? v : any/c (u16vector-length vec) → exact-nonnegative-integer? vec : u16vector? (u16vector-ref vec k) → number? vec : u16vector? k : exact-nonnegative-integer? (u16vector-set! vec k val) → void? vec : u16vector? k : exact-nonnegative-integer? val : number? (list->u16vector lst) → u16vector? lst : (listof number?) (u16vector->list vec) → (listof number?) vec : u16vector? (u16vector->cpointer vec) → cpointer? vec : u16vector?
Like make-vector, etc., but for _uint16 elements. The u16vector->cpointer function extracts a plain pointer to the underlying array.
(_u16vector mode maybe-len) _u16vector
(make-s32vector len) → s32vector? len : exact-nonnegative-integer? (s32vector val ...) → s32vector? val : number? (s32vector? v) → boolean? v : any/c (s32vector-length vec) → exact-nonnegative-integer? vec : s32vector? (s32vector-ref vec k) → number? vec : s32vector? k : exact-nonnegative-integer? (s32vector-set! vec k val) → void? vec : s32vector? k : exact-nonnegative-integer? val : number? (list->s32vector lst) → s32vector? lst : (listof number?) (s32vector->list vec) → (listof number?) vec : s32vector? (s32vector->cpointer vec) → cpointer? vec : s32vector?
Like make-vector, etc., but for _int32 elements. The s32vector->cpointer function extracts a plain pointer to the underlying array.
(_s32vector mode maybe-len) _s32vector
(make-u32vector len) → u32vector? len : exact-nonnegative-integer? (u32vector val ...) → u32vector? val : number? (u32vector? v) → boolean? v : any/c (u32vector-length vec) → exact-nonnegative-integer? vec : u32vector? (u32vector-ref vec k) → number? vec : u32vector? k : exact-nonnegative-integer? (u32vector-set! vec k val) → void? vec : u32vector? k : exact-nonnegative-integer? val : number? (list->u32vector lst) → u32vector? lst : (listof number?) (u32vector->list vec) → (listof number?) vec : u32vector? (u32vector->cpointer vec) → cpointer? vec : u32vector?
Like make-vector, etc., but for _uint32 elements. The u32vector->cpointer function extracts a plain pointer to the underlying array.
(_u32vector mode maybe-len) _u32vector
(make-s64vector len) → s64vector? len : exact-nonnegative-integer? (s64vector val ...) → s64vector? val : number? (s64vector? v) → boolean? v : any/c (s64vector-length vec) → exact-nonnegative-integer? vec : s64vector? (s64vector-ref vec k) → number? vec : s64vector? k : exact-nonnegative-integer? (s64vector-set! vec k val) → void? vec : s64vector? k : exact-nonnegative-integer? val : number? (list->s64vector lst) → s64vector? lst : (listof number?) (s64vector->list vec) → (listof number?) vec : s64vector? (s64vector->cpointer vec) → cpointer? vec : s64vector?
Like make-vector, etc., but for _int64 elements. The s64vector->cpointer function extracts a plain pointer to the underlying array.
(_s64vector mode maybe-len) _s64vector
(make-u64vector len) → u64vector? len : exact-nonnegative-integer? (u64vector val ...) → u64vector? val : number? (u64vector? v) → boolean? v : any/c (u64vector-length vec) → exact-nonnegative-integer? vec : u64vector? (u64vector-ref vec k) → number? vec : u64vector? k : exact-nonnegative-integer? (u64vector-set! vec k val) → void? vec : u64vector? k : exact-nonnegative-integer? val : number? (list->u64vector lst) → u64vector? lst : (listof number?) (u64vector->list vec) → (listof number?) vec : u64vector? (u64vector->cpointer vec) → cpointer? vec : u64vector?
Like make-vector, etc., but for _uint64 elements. The u64vector->cpointer function extracts a plain pointer to the underlying array.
(_u64vector mode maybe-len) _u64vector
(make-f32vector len) → f32vector? len : exact-nonnegative-integer? (f32vector val ...) → f32vector? val : number? (f32vector? v) → boolean? v : any/c (f32vector-length vec) → exact-nonnegative-integer? vec : f32vector? (f32vector-ref vec k) → number? vec : f32vector? k : exact-nonnegative-integer? (f32vector-set! vec k val) → void? vec : f32vector? k : exact-nonnegative-integer? val : number? (list->f32vector lst) → f32vector? lst : (listof number?) (f32vector->list vec) → (listof number?) vec : f32vector? (f32vector->cpointer vec) → cpointer? vec : f32vector?
Like make-vector, etc., but for _float elements. The f32vector->cpointer function extracts a plain pointer to the underlying array.
(_f32vector mode maybe-len) _f32vector
(make-f64vector len) → f64vector? len : exact-nonnegative-integer? (f64vector val ...) → f64vector? val : number? (f64vector? v) → boolean? v : any/c (f64vector-length vec) → exact-nonnegative-integer? vec : f64vector? (f64vector-ref vec k) → number? vec : f64vector? k : exact-nonnegative-integer? (f64vector-set! vec k val) → void? vec : f64vector? k : exact-nonnegative-integer? val : number? (list->f64vector lst) → f64vector? lst : (listof number?) (f64vector->list vec) → (listof number?) vec : f64vector? (f64vector->cpointer vec) → cpointer? vec : f64vector?
Like make-vector, etc., but for _double* elements. The f64vector->cpointer function extracts a plain pointer to the underlying array.
(_f64vector mode maybe-len) _f64vector