From b0403ab1ce1bba4de3a26d6436d739d167c93c37 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 15 Nov 2010 12:09:34 -0800 Subject: [PATCH] Fold RadixSort_() into -[NSMutableArray(Radix) radixSortUsingFunction:withContext:]. --- MobileCydia.mm | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/MobileCydia.mm b/MobileCydia.mm index 6dd79d2c..6a73c601 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 {{{ */ -- 2.47.2