C
Comp1597
I have a function with signature: unsigned f(unsigned);
My task is to read positive integers from a file (call each number x)
and to write f(x) on standard output
My code goes like this:
BEGINNING OF CODE
unsigned ComputeThis;
// ReadFromThisFile is a stream bound to a text file
while (ReadFromThisFile >> ComputeThis)
std::cout << f(ComputeThis)<<"\n";
END OF CODE
Assume that the text file is very large. Can anyone suggest
strategies to improve the efficiency of this code in terms of either
caching values of ComputeThis that occur often, or speeding up the
stream reading and writing process?
Or other efficiency gains?
Feel free to suggest general ideas or areas or computer science/ c++
to study that are relevant to this problem
Thanks a lot.
My task is to read positive integers from a file (call each number x)
and to write f(x) on standard output
My code goes like this:
BEGINNING OF CODE
unsigned ComputeThis;
// ReadFromThisFile is a stream bound to a text file
while (ReadFromThisFile >> ComputeThis)
std::cout << f(ComputeThis)<<"\n";
END OF CODE
Assume that the text file is very large. Can anyone suggest
strategies to improve the efficiency of this code in terms of either
caching values of ComputeThis that occur often, or speeding up the
stream reading and writing process?
Or other efficiency gains?
Feel free to suggest general ideas or areas or computer science/ c++
to study that are relevant to this problem
Thanks a lot.