diff options
-rw-r--r-- | MobileCydia.mm | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm index 6dd79d2..6a73c60 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -419,7 +419,20 @@ struct RadixItem_ { uint32_t key; }; -static void RadixSort_(NSMutableArray *self, size_t count, struct RadixItem_ *swap) { +@implementation NSMutableArray (Radix) + +- (void) radixSortUsingFunction:(SKRadixFunction)function withContext:(void *)argument { + size_t count([self count]); + struct RadixItem_ *swap(new RadixItem_[count * 2]); + + for (size_t i(0); i != count; ++i) { + RadixItem_ &item(swap[i]); + item.index = i; + + id object([self objectAtIndex:i]); + item.key = function(object, argument); + } + struct RadixItem_ *lhs(swap), *rhs(swap + count); static const size_t width = 32; @@ -469,23 +482,6 @@ static void RadixSort_(NSMutableArray *self, size_t count, struct RadixItem_ *sw delete [] swap; } -@implementation NSMutableArray (Radix) - -- (void) radixSortUsingFunction:(SKRadixFunction)function withContext:(void *)argument { - size_t count([self count]); - struct RadixItem_ *swap(new RadixItem_[count * 2]); - - for (size_t i(0); i != count; ++i) { - RadixItem_ &item(swap[i]); - item.index = i; - - id object([self objectAtIndex:i]); - item.key = function(object, argument); - } - - RadixSort_(self, count, swap); -} - @end /* }}} */ /* Insertion Sort {{{ */ |