parrotcode: Multi-dimensional Array | |
Contents | PMCs |
classes/multiarray.pmc - Multi-dimensional Array
MultiArray
extends Array
to provide a multi-dimensional array.
This is one way for calculating offsets in 2 dimensional space.
MULTIDIM CALC OFFSET
Algorithm:
i + j*Ni + k*Ni*Nj + l*Ni*Nj*Nk ...
where i,j,k,l... are coordinates in a multidimensional space and Ni,Nj,Nk... are the lengths of the dimensions.
Limitations: the array can only expand in the last dimension The first (n-1) dimensions of a n-dimensional array are fixed and layed out at array creation.
static INTVAL calc_offset(Interp *interpreter, List *list, PMC *key)
*key
.void init()
Array
. There is no initialization.INTVAL get_integer_keyed(PMC *key)
*key
.FLOATVAL get_number_keyed(PMC *key)
*key
.STRING *get_string_keyed(PMC *key)
*key
.PMC *get_pmc_keyed (PMC *key)
*key
.void set_integer_keyed(PMC *key, INTVAL value)
value
at *key
.void set_number_keyed(PMC *key, FLOATVAL value)
value
at *key
.void set_string_keyed(PMC *key, STRING *value)
value
at *key
.void set_pmc_keyed(PMC *dest_key, PMC *src)
Initial revision by Josef Hook <joh@stacken.kth.se>
1.6 Based on list.c by Leopold Toetsch <lt@toetsch.at>
|