Spaces To Tabs

This commit is contained in:
NeeEoo
2023-04-22 12:15:49 +02:00
parent 2b2990ae30
commit 85cdfdeb10
108 changed files with 23942 additions and 23944 deletions
+15 -15
View File
@@ -3,7 +3,7 @@ package funkin.backend.utils;
/**
* All types of utils only usable in a sorted array.
*/
class SortedArrayUtil {
class SortedArrayUtil {
/**
* Gets the index of a possible new element of an Array of T using an efficient algorithm.
* @param array Array of T to check in
@@ -15,7 +15,7 @@ package funkin.backend.utils;
if (getVal(array[0]) > val) return 0; // in case its the minimum
if (getVal(array[array.length-1]) < val) return array.length; // in case its the maximum
// binary search
// binary search
var iMin:Int = 0;
var iMax:Int = array.length-1;
@@ -25,25 +25,25 @@ package funkin.backend.utils;
i = Math.floor((iMin + iMax) / 2);
mid = getVal(array[i]);
if (mid < val)
iMin = i+1
iMin = i+1
else if (mid > val)
iMax = i-1;
else {
iMin = i;
break;
}
iMin = i;
break;
}
}
return iMin;
}
/**
* Adds to a sorted array, using binary search.
* @param array Array to add to
* @param val Value to add
* @param getVal Function that returns the value that needs to be sorted
*/
public static inline function addSorted<T>(array:Array<T>, val:T, getVal:T->Float) {
/**
* Adds to a sorted array, using binary search.
* @param array Array to add to
* @param val Value to add
* @param getVal Function that returns the value that needs to be sorted
*/
public static inline function addSorted<T>(array:Array<T>, val:T, getVal:T->Float) {
if (val != null)
array.insert(binarySearch(array, getVal(val), getVal), val);
}
array.insert(binarySearch(array, getVal(val), getVal), val);
}
}