Functions | |
bool | isARRAY (SatAddr src) |
is the object at src an ARRAY object? | |
int | ARRAYnibbles (SatAddr src) |
Return the number of nibbles in a ARRAY object. | |
SatAddr | makeARRAY (SatAddr element, int numDimensions, int dim1,...) |
Create an N-dimensional array. | |
SatAddr | ARRAYgetItem (SatAddr array, SatAddr dst, int idx1,...) |
Get a copy of an item in an array. | |
int | ARRAYputItem (SatAddr array, SatAddr item, int idx1,...) |
Put an item into an array. | |
SatAddr | ARRAYfirstItem (SatAddr array, SatAddr dst, SatAddr *iter) |
Get the first item in an array. | |
SatAddr | ARRAYnextItem (SatAddr array, SatAddr dst, SatAddr *iter) |
Return the next item in an array. | |
int | ARRAYnumDimensions (SatAddr array) |
Return the number of dimensions in an array. | |
int | ARRAYgetDimension (SatAddr array, int dimensionNumber) |
Get the size of the i'th dimension. | |
int | ARRAYgetElProlog (SatAddr array) |
get the prolog value of the items stored in the array. | |
int | ARRAYgetElementBody (SatAddr array, SatAddr *elementBody, int idx1,...) |
Get the Saturn address of an element body in an array. | |
int | ARRAYelementSize (SatAddr array, SatAddr element) |
Get the size of an element body in an array. | |
SatAddr | ARRAYfirstElement (SatAddr array) |
Get the first element body in an array. | |
SatAddr | ARRAYnextElement (SatAddr array, SatAddr prev) |
Return the next element body in an array. |
For lower level access, functions are also provided to access the object bodies directly.
Get the size of an element body in an array.
Given an array and a pointer to an element body in an array, return the size of the element in the array. Since the array contains the body of an object, the size needed to reconstitute this object is 5+ARRAYelementSize().
array | The ARRAY object | |
element | The element body |
Get the first element body in an array.
array | The ARRAY object |
Get the first item in an array.
array | The ARRAY object | |
dst | If non-null, then the array item, including its prolog will be copied here. Otherwise space will be allocated in TEMPOb for the item and it will be copied there. | |
iter | A pointer to a SatAddr variable. This will be set to a value that can be passed to ARRAYnextItem() to get the next item. |
int ARRAYgetDimension | ( | SatAddr | array, | |
int | dimensionNumber | |||
) |
Get the size of the i'th dimension.
Dimensions are numbered from zero, so valid dimensions are 0, 1, 2, 3, etc).
array | The ARRAY object | |
dimensionNumber | The dimension number (0, 1, 2, etc) |
Get the Saturn address of an element body in an array.
Arrays store object bodies, without their prologs. This function gets the address of one such body.
array | The ARRAY object | |
elementBody | Address of a SatAddr variable. The Saturn address of the element's body will be stored here. | |
idx1 | Index value of the array's first dimension. NOTE! In keeping with C conventions, the index values start at zero, not 1!! | |
idxN | Index value of the n'th index. You must pass as many indices as there are dimensions. |
int ARRAYgetElProlog | ( | SatAddr | array | ) |
get the prolog value of the items stored in the array.
array | The ARRAY object |
Get a copy of an item in an array.
array | The ARRAY object | |
dst | If non-null, then the array item, including its prolog will be copied here. Otherwise space will be allocated in TEMPOb for the item and the it will be copied there. | |
idx1 | Index value of the array's first dimension. NOTE! In keeping with C conventions, the index values start at zero, not 1!! | |
idxN | Index values for the rest of the dimensions. You must pass as many indices as there are dimensions. |
Because arrays store object bodies separate from object prologs, we must copy the object and prolog to a separate place to have meaningful access to it.
This function's speed depends on greatly on whether the array contains fixed-sized objects. If the objects are all the same size (like REAL numbers), then it uses arithemetic to compute the address of the appropriate item. Otherwise the funtion is forced to scan through the array to find the right one.
Return the next element body in an array.
Return the next item in an array.
array | The ARRAY object | |
dst | If non-null, then the array item's prolog and body will be copied here. Otherwise space will be allocated in TEMPOb for the item and it will be copied there. | |
iter | A pointer to a SatAddr variable that was previously passed to ARRAYfirstItem() or ARRAYnextItem(). This will be updated to a value that can be passed to ARRAYnextItem() again to get the following item. |
int ARRAYnibbles | ( | SatAddr | src | ) |
Return the number of nibbles in a ARRAY object.
src | Saturn address of a ARRAY object. |
int ARRAYnumDimensions | ( | SatAddr | array | ) |
Return the number of dimensions in an array.
array | The ARRAY object |
Put an item into an array.
array | The ARRAY object | |
item | The item to copy into the array. | |
idx1 | Index value of the array's first dimension. NOTE! In keeping with C conventions, the index values start at zero, not 1!! | |
idxN | Index values for the rest of the dimensions. You must pass as many indices as there are dimensions. |
bool isARRAY | ( | SatAddr | src | ) |
is the object at src an ARRAY object?
src | Saturn address of an object |
Create an N-dimensional array.
Example: make a 4x5 array of real numbers. Initialize each value with 1.0
SatAddr myArray = makeARRAY(REALencode(1.0, 0), 2, 4, 5);
Example: make a 1-dimensional array of 10 lists where each list is { 1. 2. 3. }
SatAddr theList = LISTencode(0, REALencode(1., 0), REALencode(2., 0), REALencode(3.,0), 0)); SatAddr myArray = makeARRAY(theList, 1, 10);