Suppose, we have an external library that can do calculations very fast (most of the times multithreaded) on an array of double precision floating point numbers. For convenience, I write my code in an object oriented way so I get an array of objects. Each object has a property holding a double value. The naive approach to make use of the powerful external library is something like this:
double temp[N];
for i from 1 to N
temp[i] = objectArray[i].property;
end
However, this takes time and additional memory to hold the temp array. Is there a better way to do that?
It is a general question, but I basically want to this in C++.