Created
December 6, 2012 22:28
-
-
Save shannah/4229069 to your computer and use it in GitHub Desktop.
Native method with towers of Hanoi benchmark.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "com_mycompany_myapp_NativeTowersOfHanoiImpl.h" | |
void com_mycompany_myapp_NativeTowersOfHanoiImpl_move(int n, int startPole, int endPole) { | |
if (n == 0) { | |
return; | |
} | |
int intermediatePole = 6 - startPole - endPole; | |
com_mycompany_myapp_NativeTowersOfHanoiImpl_move(n - 1, startPole, intermediatePole); | |
com_mycompany_myapp_NativeTowersOfHanoiImpl_move(n - 1, intermediatePole, endPole); | |
} | |
@implementation com_mycompany_myapp_NativeTowersOfHanoiImpl | |
-(int)runCalculation{ | |
com_mycompany_myapp_NativeTowersOfHanoiImpl_move(30, 1, 3); | |
return YES; | |
} | |
-(BOOL)isSupported{ | |
return YES; | |
} | |
@end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment