hey
I'm currently building a new data structures that will be used in monte carlo generators (and so will be constructed several milion times) and I'm wondering what's the best way (computer-speed-wise) to pass the data to the constructor.
I am currently doing it using references and passing arrays as pointers like this:
Code:
class particle{
public:
particle(double *ar,int &id):IDup(id){
for (int i=0;i<5;++i)
Pup[i]=ar[i];
}
int IDup;
double Pup[5];
};
I'm assuming that since using referencies has no need to create a temporary memory slot it's more efficient (if there is a better way, I'm all ears).
As for the arrays: is there a way for me to pass them as reference as well? (not using c++11), I'm using arrays instead of vectors as much as I can because I assume that vectors, being more advanced data structures, would take more time to create.