Extensions Resize

void array:resize ( number i1, i2, ... in )

Resizes and/or changes the dimensionality of the array.  The number of dimensions provided as parameters does not need to match the previous dimensionality of the array.  The new size of the array will be product of the parameters.

The contents of the array (from a linear perspective) are not changed by a call to resize.  That is, if an array is expanded, the existing contents will persist, but if an array is truncated, then the elements at the end will be lost.  However, if any dimension size (after the first dimension) of a multi-dimensional array is changed, then the data will no longer be at their previous indexes.

Parameters

in One or more dimension sizes 

Return Values

None.

Error Conditions

If there is not enough available memory in the system to satisfy the reqested size, this function will signal an error.  The existing array will be left unchanged at its original size.

Example

-- Create an array of 1000 doubles
local arr = array.new(1000)
 
-- This call effectively leaves the array unchanged,
-- but adds 3D indexing to the linear array
arr:resize(10, 10, 10)
 
-- This call physically extends the array without
-- destroying the existing indexing
arr:resize(15, 10, 10)
 
-- This call extends the array and destroys the
-- existing indexing
arr:resize(15, 10, 15)

Copyright 2010 Justin Aquadro