4 Using MWArra y Classes
if (x != null)
x.dispose();
throw new MWException(e.getMessage());
}
}
This me tho d creates a n ew MWCellArray of the necessary size. Next, the
code loops over the number of elements in the supplied arrays. For each loop
iteration, a temporary
MWNumericArray, x, is created for the current cell and
initialized with the contents of
re[k-1] and im[k-1] (the loop variable, k,is
one-based). A shared copy of the temporary numeric array is then assigned to
the cell at
k using the set method.
Thenativeresourcesassociatedwith
x are freed when you call dispose.Ifan
exception i s thrown during the construction phase, the partially constructed
cell array and the temporary numeric array are disposed of, if necessary.
The exception is then rethrown as an
MWException. If everything goes well,
the
MWCellArray is returned.
Accessing MWCellArray Elements
The MWCellArray class provides methods for a ccessing and modifying array
data in the form of
get and set methods. The following table lists the get
and set methods.
Method Usage
get(int)
Returns the element at the one-based index as a Java
array (inherited f rom
MWArray).
get(int)
Returns the elem ent at the one-based index array as
a Jav a array (inherited from
MWArray).
getCell(int)
Returns the element at the one-based index as an
MWArray instance.
getCell(int[])
Returns the element at the one-based index array
as an
MWArray instance.
4-34
Komentarze do niniejszej Instrukcji