In C++, whenever a function creates many (hundreds or thousands of) values, I used to have the caller pass an array that my function then fills with the output values:
I'd use something like
std::auto_ptr > computeValues(int input); { std::auto_ptr > r(new std::vector); r->push_back(...) // Hundreds of these return r; }
No copying overhead in the return or risk of leaking (if you use auto_ptr correctly in the caller).