An array is an aggregate of data of a common type, which can be accessed with one or more nonnegative indices. ECL stores arrays as a C structure with a pointer to the region of memory which contains the actual data. The cell of an array datatype varies depending on whether it is a vector, a bytevector, a multidimensional array or a string.
If x
contains a vector, you can access the following fields:
|
The type of the elements of the vector. |
|
The maximum number of elements. |
|
Actual number of elements in the vector or "fill pointer". |
|
Union of pointers of different types. You should choose the right pointer
depending on |
|
Whether |
If x
contains a multidimensional array, the cell elements become
|
The type of the elements of the array. |
|
Number of elements in the array. |
|
Number of dimensions of the array. |
|
Array with the dimensions of the array. The elements range from
|
|
Union of pointers to the actual data. You should choose the right pointer
depending on |
|
Whether |
Bitvectors and strings are treated separately.
Each array is of an specialized type which is the type of the elements of the
array. ECL has arrays only a few following specialized types, and for each
of these types there is a C integer which is the corresponding value of
x->array.elttype
or x->vector.elttype
. We list those types
together with the C constant that denotes that type:
|
|
|
|
|
|
|
|
|
|
|
|
Function: cl_elttypearray_elttype
(cl_objecto
)Returns the element type of the array
o
, which can be a string, a bitvector, vector, or a multidimensional array. For example, the codearray_elttype(c_string_to_object("\"AAA\""))
returnsaet_ch
, while thearray_elttype(c_string_to_object("#(A B C)"))
returnsaet_object
.
Function: cl_objectaref
(cl_objectarray
, cl_indexindex
)Function: cl_objectaset
(cl_objectarray
, cl_indexindex
, cl_objectvalue
)These functions are used to retrieve and set the elements of an array. The elements are accessed with one index,
index
, as in the lisp functionROW-MAJOR-AREF
. For examplecl_object array = c_string_to_object("#2A((1 2) (3 4))"); cl_object x = aref(array, 3); cl_print(1, x); /* Outputs 4 */ aset(array, 3, MAKE_FIXNUM(5)); cl_print(1, array); /* Outputs #2A((1 2) (3 5)) */
Function: cl_objectaref1
(cl_objectvector
, cl_indexindex
)Function: cl_objectaset1
(cl_objectvector
, cl_indexindex
, cl_objectvalue
)These functions are similar to
aref
andaset
, but they operate on vectors.cl_object array = c_string_to_object("#(1 2 3 4)"); cl_object x = aref1(array, 3); cl_print(1, x); /* Outputs 4 */ aset1(array, 3, MAKE_FIXNUM(5)); cl_print(1, array); /* Outputs #(1 2 3 5) */