Skip to content

Commit

Permalink
Change tabs to softtabs
Browse files Browse the repository at this point in the history
  • Loading branch information
KeeVeeGames committed Jun 22, 2020
1 parent ea6e6e0 commit 32c680f
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 126 deletions.
102 changes: 51 additions & 51 deletions quicksort_22/scripts/array_sort/array_sort.gml
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
/// @function array_sort(array, ascending)
/// @param {*[]} array Array to sort
/// @param {bool} ascending Whether the values should be ascending (true) or descending (false) order
/// @description Modifies the original array, sorting it with the quicksort algorithm
/// @function array_sort(array, ascending)
/// @param {*[]} array Array to sort
/// @param {bool} ascending Whether the values should be ascending (true) or descending (false) order
/// @description Modifies the original array, sorting it with the quicksort algorithm

var array = argument0;
var ascending = argument1;

var compare;

if (ascending) {
compare = __compare_ascending;
compare = __compare_ascending;
} else {
compare = __compare_descending;
compare = __compare_descending;
}

var length = array_length_1d(array);

var i, j;
var lb, ub;
var lb_stack = [], ub_stack = [];

var stack_pos = 1;
var pivot_pos;
var pivot;
var temp;

lb_stack[1] = 0;
ub_stack[1] = length - 1;

do {
lb = lb_stack[stack_pos];
ub = ub_stack[stack_pos];
stack_pos--;
do {
pivot_pos = (lb + ub) >> 1;
i = lb;
j = ub;
pivot = array[pivot_pos];
do {
while (script_execute(compare, array[i], pivot)) i++;
while (script_execute(compare, pivot, array[j])) j--;
if (i <= j) {
temp = array[i];
array[@ i] = array[j];
array[@ j] = temp;
i++;
j--;
}
} until (i > j);
if (i < pivot_pos) {
if (i < ub) {
stack_pos++;
lb_stack[stack_pos] = i;
ub_stack[stack_pos] = ub;
}
ub = j;
} else {
if (j > lb) {
stack_pos++;
lb_stack[stack_pos] = lb;
ub_stack[stack_pos] = j;
}
lb = i;
}
} until (lb >= ub);
lb = lb_stack[stack_pos];
ub = ub_stack[stack_pos];
stack_pos--;
do {
pivot_pos = (lb + ub) >> 1;
i = lb;
j = ub;
pivot = array[pivot_pos];
do {
while (script_execute(compare, array[i], pivot)) i++;
while (script_execute(compare, pivot, array[j])) j--;
if (i <= j) {
temp = array[i];
array[@ i] = array[j];
array[@ j] = temp;
i++;
j--;
}
} until (i > j);
if (i < pivot_pos) {
if (i < ub) {
stack_pos++;
lb_stack[stack_pos] = i;
ub_stack[stack_pos] = ub;
}
ub = j;
} else {
if (j > lb) {
stack_pos++;
lb_stack[stack_pos] = lb;
ub_stack[stack_pos] = j;
}
lb = i;
}
} until (lb >= ub);
} until (stack_pos == 0);
2 changes: 1 addition & 1 deletion quicksort_23/quicksort_23.yyp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

148 changes: 74 additions & 74 deletions quicksort_23/scripts/array_sort/array_sort.gml
Original file line number Diff line number Diff line change
@@ -1,76 +1,76 @@
/// @function array_sort(array, ascending)
/// @param {*[]} array Array to sort
/// @param {bool} ascending Whether the values should be ascending (true) or descending (false) order
/// @description Modifies the original array, sorting it with the quicksort algorithm
/// @function array_sort(array, ascending)
/// @param {*[]} array Array to sort
/// @param {bool} ascending Whether the values should be ascending (true) or descending (false) order
/// @description Modifies the original array, sorting it with the quicksort algorithm
function array_sort(_array, ascending) {
var array = _array;
var compare;
if (ascending) {
compare = function(a, b) {
return a < b;
}
} else {
compare = function(a, b) {
return a > b;
}
}
var length = array_length(array);
var i, j;
var lb, ub;
var lb_stack = [], ub_stack = [];
var stack_pos = 1;
var pivot_pos;
var pivot;
var temp;
lb_stack[1] = 0;
ub_stack[1] = length - 1;
do {
lb = lb_stack[stack_pos];
ub = ub_stack[stack_pos];
stack_pos--;
do {
pivot_pos = (lb + ub) >> 1;
i = lb;
j = ub;
pivot = array[pivot_pos];
do {
while (compare(array[i], pivot)) i++;
while (compare(pivot, array[j])) j--;
if (i <= j) {
temp = array[i];
array[@ i] = array[j];
array[@ j] = temp;
i++;
j--;
}
} until (i > j);
if (i < pivot_pos) {
if (i < ub) {
stack_pos++;
lb_stack[stack_pos] = i;
ub_stack[stack_pos] = ub;
}
ub = j;
} else {
if (j > lb) {
stack_pos++;
lb_stack[stack_pos] = lb;
ub_stack[stack_pos] = j;
}
lb = i;
}
} until (lb >= ub);
} until (stack_pos == 0);
var array = _array;
var compare;
if (ascending) {
compare = function(a, b) {
return a < b;
}
} else {
compare = function(a, b) {
return a > b;
}
}
var length = array_length(array);
var i, j;
var lb, ub;
var lb_stack = [], ub_stack = [];
var stack_pos = 1;
var pivot_pos;
var pivot;
var temp;
lb_stack[1] = 0;
ub_stack[1] = length - 1;
do {
lb = lb_stack[stack_pos];
ub = ub_stack[stack_pos];
stack_pos--;
do {
pivot_pos = (lb + ub) >> 1;
i = lb;
j = ub;
pivot = array[pivot_pos];
do {
while (compare(array[i], pivot)) i++;
while (compare(pivot, array[j])) j--;
if (i <= j) {
temp = array[i];
array[@ i] = array[j];
array[@ j] = temp;
i++;
j--;
}
} until (i > j);
if (i < pivot_pos) {
if (i < ub) {
stack_pos++;
lb_stack[stack_pos] = i;
ub_stack[stack_pos] = ub;
}
ub = j;
} else {
if (j > lb) {
stack_pos++;
lb_stack[stack_pos] = lb;
ub_stack[stack_pos] = j;
}
lb = i;
}
} until (lb >= ub);
} until (stack_pos == 0);
}

0 comments on commit 32c680f

Please sign in to comment.