chunk-vector

  1. chunk-vector
    1. Description
    2. Author
    3. Requirements
    4. Documentation
      1. Procedures
      2. Example

Description

A dyn-vector like library capable of storing other srfi-4 vectors inside a dense array.

Author

Richard van Roy (pluizer)

Requirements

none

Documentation

Procedures

[procedure] (make-f32chunk-vector size [size-hint])
[procedure] (make-f64chunk-vector size [size-hint])
[procedure] (make-s8chunk-vector size [size-hint])
[procedure] (make-s16chunk-vector size [size-hint])
[procedure] (make-s32chunk-vector size [size-hint])
[procedure] (make-u8chunk-vector size [size-hint])
[procedure] (make-u16chunk-vector size [size-hint])
[procedure] (make-u32chunk-vector size [size-hint])

Create a new chunk vector with a chunk-size of size.

[procedure] (f32chunk-vector-remove! vector index)
[procedure] (f64chunk-vector-remove! vector index)
[procedure] (s8chunk-vector-remove! vector index)
[procedure] (s16chunk-vector-remove! vector index)
[procedure] (s32chunk-vector-remove! vector index)
[procedure] (u8chunk-vector-remove! vector index)
[procedure] (u16chunk-vector-remove! vector index)
[procedure] (u32chunk-vector-remove! vector index)

Removes a chunk from the vector using its index.

[procedure] (f32chunk-vector-set! vector index value)
[procedure] (f64chunk-vector-set! vector index value)
[procedure] (s8chunk-vector-set! vector index value)
[procedure] (s16chunk-vector-set! vector index value)
[procedure] (s32chunk-vector-set! vector index value)
[procedure] (u8chunk-vector-set! vector index value)
[procedure] (u16chunk-vector-set! vector index value)
[procedure] (u32chunk-vector-set! vector index value)

Changed the value of a chunk using its index.

[procedure] (f32chunk-vector-push! vector value)
[procedure] (f64chunk-vector-push! vector value)
[procedure] (s8chunk-vector-push! vector value)
[procedure] (s16chunk-vector-push! vector value)
[procedure] (s32chunk-vector-push! vector value)
[procedure] (u8chunk-vector-push! vector value)
[procedure] (u16chunk-vector-push! vector value)
[procedure] (u32chunk-vector-push! vector value)

Pushes a new chunk to the vector.

[procedure] (f32chunk-vector-ref vector index)
[procedure] (f64chunk-vector-ref vector index)
[procedure] (s8chunk-vector-ref vector index)
[procedure] (s16chunk-vector-ref vector index)
[procedure] (s32chunk-vector-ref vector index)
[procedure] (u8chunk-vector-ref vector index)
[procedure] (u16chunk-vector-ref vector index)
[procedure] (u32chunk-vector-ref vector index)

Returns the data at index.

[procedure] (f32chunk-vector-length vector)
[procedure] (f64chunk-vector-length vector)
[procedure] (s8chunk-vector-length vector)
[procedure] (s16chunk-vector-length vector)
[procedure] (s32chunk-vector-length vector)
[procedure] (u8chunk-vector-length vector)
[procedure] (u16chunk-vector-length vector)
[procedure] (u32chunk-vector-length vector)

Returns the number of chunks in the vector.

[procedure] (f32chunk-vector->pointer vector)
[procedure] (f64chunk-vector->pointer vector)
[procedure] (s8chunk-vector->pointer vector)
[procedure] (s16chunk-vector->pointer vector)
[procedure] (s32chunk-vector->pointer vector)
[procedure] (u8chunk-vector->pointer vector)
[procedure] (u16chunk-vector->pointer vector)
[procedure] (u32chunk-vector->pointer vector)

Returns a pointer to the dense foreign array where the data is stored.

Example

(use chunk-vector)

;; Create a chunk-vector that holds f32vectors with the size of 2.
(define v (make-f32chunk-vector 2))

(define index-a (f32chunk-vector-push! v (f32vector 1 2)))

(define index-b (f32chunk-vector-push! v (f32vector 3 4)))

(define index-c (f32chunk-vector-push! v (f32vector 7 8)))

(f32chunk-vector-remove! v index-c)

(f32chunk-vector-set! v index-b (f32vector 0 0))

(print (f32chunk-vector-ref v index-a)) ; => #f32(1.0 2.0)

(print (f32chunk-vector-ref v index-b)) ; => #f32(0.0 0.0)

(print (f32chunk-vector-ref v index-c)) ; undefined