Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shannah/4229069 to your computer and use it in GitHub Desktop.
Save shannah/4229069 to your computer and use it in GitHub Desktop.
Native method with towers of Hanoi benchmark.
#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