Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Serializes the current instance of the Array class.
Syntax
public container pack()
Run On
Called
Return Value
Type: container
A container that contains the current instance of the Array class.
Remarks
The container created by this method contains three elements before the first element from the array:
A version number for the container.
An integer that identifies the data type of the array elements.
The number of elements in the array.
If the values of the array are objects, the pack method is called on each object to yield a subcontainer.
Examples
The following example creates an array of integers and adds some values to it. The pack method is used to pack the array into a container, and the container is then used to create a new array.
{
int i;
container packedArray;
// Create an integer array
Array ia = new Array (Types::Integer);
Array iacopy;
// Write some elements in it
for (i = 1; i< 10; i++)
{
ia.value(i, i*2);
}
// Pack the array
packedArray = ia.pack();
// Unpack the array
iacopy = Array::create(packedArray);
// Check the values
for (i = 1; i< 10; i++)
{
if (iacopy.value(i) != 2*i)
{
print "Error!";
}
}
pause;
}