Created
January 3, 2012 08:21
-
-
Save winsonwq/1554056 to your computer and use it in GitHub Desktop.
BubbleSort of Mr.Async.Interpreter
This file contains hidden or 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
| // 算法本身 | |
| for(var i = 0 ; i < arr.length - 1 ; i++){ | |
| for(var ii = i + 1; ii < arr.length ; ii++){ | |
| if(arr[i] > arr[ii]) | |
| normalSwap(arr, i, ii); | |
| } | |
| } | |
| // 利用了Mr.Async.Interpreter的方式 | |
| eval(Mr.Async.recode(function(){ | |
| for(var i = 0 ; i < arr.length - 1 ; i++){ | |
| for(var ii = i + 1; ii < arr.length ; ii++){ | |
| if(arr[i] > arr[ii]) | |
| $await(asyncSwap(arr, i, ii)); | |
| } | |
| } | |
| })); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment