diff options
Diffstat (limited to 'Menes')
-rw-r--r-- | Menes/radixSortWithSelector.h | 1 | ||||
-rw-r--r-- | Menes/radixSortWithSelector.mm | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/Menes/radixSortWithSelector.h b/Menes/radixSortWithSelector.h index d148cb3..4438584 100644 --- a/Menes/radixSortWithSelector.h +++ b/Menes/radixSortWithSelector.h @@ -46,6 +46,7 @@ typedef uint32_t (*MenesRadixSortFunction)(id, void *); @interface NSMutableArray (MenesRadixSortWithSelector) - (void) radixSortUsingFunction:(MenesRadixSortFunction)function withContext:(void *)argument; +- (void) radixSortUsingSelector:(SEL)selector; @end #endif//Menes_radixSort_H diff --git a/Menes/radixSortWithSelector.mm b/Menes/radixSortWithSelector.mm index 949a14b..f61dd99 100644 --- a/Menes/radixSortWithSelector.mm +++ b/Menes/radixSortWithSelector.mm @@ -41,6 +41,8 @@ #include "Menes/radixSortWithSelector.h" +#include <objc/runtime.h> + struct RadixItem_ { size_t index; uint32_t key; @@ -109,4 +111,12 @@ struct RadixItem_ { delete [] swap; } +- (void) radixSortUsingSelector:(SEL)selector { + if ([self count] == 0) + return; + + IMP imp(class_getMethodImplementation([[self lastObject] class], selector)); + [self radixSortUsingFunction:reinterpret_cast<MenesRadixSortFunction>(imp) withContext:selector]; +} + @end |