I'm trying to integrate some GCD into my code, and have found that a severe bottleneck is a bubble comparison I am performing between objects in a large array. Here is the original code:
NSUInteger count = [arrayToDoWorkOn count];
for (int i = 0; i < count; i++)
{
for (int j = i + 1; j < count; j++)
{
[[arrayToDoWorkOn objectAtIndex:i] compare:[arrayToDoWorkOn objectAtIndex:j]];
}
}
Get my drift? So a lot of other fast enumeration tasks can be easily GCD'd by converting
for (id obj in array)
{
[obj aMessage:stuff];
}
to:
[array enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop)
{
[obj aMessage:stuff];
}];
Is there a way to convert my look-ahead-sorta-bubble-sorta-algorithm-thing to something that I can feed to a GCD block implementation?