August 2011
Intermediate to advanced
552 pages
23h 48m
English
Even something as simple as a for-loop iterating over data performing work can be enhanced by GCD. The classic way of iterating through an array and performing an operation on each element is through a for loop.
enum {
kNumberCount = 200000
};
static int numbers[kNumberCount];
static int results[kNumberCount];
for (int i = 0; i < kNumberCount; i++) {
results[i] = Work (numbers, i);
}
You could walk through the array doing work that is not really interrelated and then sift through the work to make the final conclusion, like a map/reduce operation.
You can ...
Read now
Unlock full access