November 1999
Intermediate to advanced
336 pages
6h 29m
English
The STL is regarded by many to have excellent performance. The general trend is to discourage the programmer from even thinking about surpassing the STL performance with home-grown implementations. Although we agree with this notion, for the most part, we would still like to take a closer look at those conceptions. To learn more about it, we will take a few shots at exceeding the STL performance and see how it goes.
We have encountered the accumulate() function earlier in this chapter, using it to sum up a collection of integers. Let's see if we can improve upon it with a home-grown implementation:
int myIntegerSum(int *a, int size) { int sum = 0; int *begin = &a[0]; int *end = &a[size]; for (int *p=begin; p != end; p++) { sum ...Read now
Unlock full access