Merge branch 'main' into translations-system

This commit is contained in:
NeeEoo
2024-04-12 12:40:09 +02:00
11 changed files with 37 additions and 26 deletions
+19 -2
View File
@@ -614,13 +614,14 @@ class CoolUtil
* @return Index, or -1 if unsuccessful.
*/
public static inline function indexOfFromLast<T>(array:Array<T>, element:T):Int {
var i = array.length - 1;
/*var i = array.length - 1;
while(i >= 0) {
if (array[i] == element)
break;
i--;
}
return i;
return i;*/
return array.lastIndexOf(element);
}
/**
@@ -725,6 +726,22 @@ class CoolUtil
});
return array;
}
public static inline function pushOnce<T>(array:Array<T>, element:T) {
#if (haxe >= "4.0.0")
if (!array.contains(element))
array.push(element);
#else
if (array.indexOf(element) == -1)
array.push(element);
#end
}
#if !(haxe >= "4.0.0")
public static inline function contains<T>(array:Array<T>, element:T) {
return array.indexOf(element) != -1;
}
#end
}
/**