Specialized array words
Factor handbook » The language » Collections » Specialized arrays

Prev:SPECIALIZED-ARRAYS:
Next:Passing specialized arrays to C functions


The SPECIALIZED-ARRAY: and SPECIALIZED-ARRAYS: parsing words generate specialized array types if they haven't been generated already and add the following words to the vocabulary search path, where T is the C type in question:
T-arrayThe class of arrays with elements of type T
<T-array>Constructor for arrays with elements of type T; stack effect ( len -- array )
(T-array)Constructor for arrays with elements of type T, where the initial contents are uninitialized; stack effect ( len -- array )
<direct-T-array>Constructor for arrays with elements of type T backed by raw memory; stack effect ( alien len -- array )
T-array{Literal syntax, consists of a series of values terminated by }

Behind the scenes, these words are placed in a vocabulary named specialized-arrays.instances.T, however this vocabulary should not be placed in a USING: form directly. Instead, always use SPECIALIZED-ARRAY: or SPECIALIZED-ARRAYS:. This ensures that the vocabulary can get generated the first time it is needed.

Additionally, special versions of the standard <slice>, head, and tail sequence operations are provided for specialized arrays to create a new specialized array object sharing storage with a subsequence of an existing array:
direct-slice ( from to seq -- seq' )

direct-head ( seq n -- seq' )

direct-tail ( seq n -- seq' )

direct-head* ( seq n -- seq' )

direct-tail* ( seq n -- seq' )