[Insight-users] how to allocate memmory to itk::Array

Mark Foskey mark_foskey at unc . edu
Wed, 03 Sep 2003 11:03:04 -0400


I believe you can do something like:

typedef itk::Array<int> ArrayType;
ArrayType myArray;  // no space allocated

// ...more code

myArray = ArrayType(sizeOfArray);

This will construct a new array and then perform an assignment, so it 
won't be terribly efficient.  But the whole point of itk::Array is that 
the size is constant -- allocating memory later would be changing the 
size from 0 to something else.  If you really want something that works 
like an std::vector, use itk::VectorContainer.

Zhiyong Xie wrote:
> I want create an empty itk::Array and allocate memmory latter.
> can anyone tell me how to do it? it seems not support "reserve"
> function.
> 
> thanks
> 
> Sean
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk . org
> http://www . itk . org/mailman/listinfo/insight-users

-- 
Mark Foskey    (919) 843-5436  Computer-Aided Diagnosis and Display Lab
mark_foskey at unc . edu            Department of Radiology, CB 7515, UNC
http://www . cs . unc . edu/~foskey  Chapel Hill, NC  27599-7515