Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: webkit/data/test_shell/sort/sort-quick.js

Issue 401923005: webkit: Remove all files from test_shell/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/data/test_shell/sort/sort-insertion.js ('k') | webkit/data/test_shell/test.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // quicksort
2
3 function sort_quick(sort, left, right) {
4 if (arguments.length == 1) {
5 left = 0;
6 right = sort.size - 1;
7 }
8 if (left < right) {
9 var pivot = left + Math.floor(Math.random()*(right-left));
10 //var pivot = Math.floor(left + (right-left)/2);
11 partition(sort, left, right, pivot);
12 }
13 }
14
15 function partition(sort, left, right, pivot) {
16 sort.swap(pivot, right);
17 sort.add_work(function(){partition_step(sort, left, right, pivot, left, left); });
18 }
19
20 function partition_step(sort, left, right, pivot, i, j) {
21 if (i < right) {
22 if (sort.compare(i, right) <= 0) {
23 sort.swap(i, j);
24 j++;
25 }
26 i++;
27 sort.add_work(function(){partition_step(sort, left, right, pivot, i, j)});
28 } else {
29 sort.swap(j, right);
30 sort.add_work(function(){sort_quick(sort, left, j-1)});
31 sort.add_work(function(){sort_quick(sort, j+1, right)});
32 }
33 }
34
OLDNEW
« no previous file with comments | « webkit/data/test_shell/sort/sort-insertion.js ('k') | webkit/data/test_shell/test.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698