mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-05 14:24:28 +00:00
26 lines
570 B
Haxe
26 lines
570 B
Haxe
package funkin.util.tools;
|
|
|
|
/**
|
|
* A static extension which provides utility functions for Arrays.
|
|
*/
|
|
class ArrayTools
|
|
{
|
|
/**
|
|
* Returns a copy of the array with all duplicate elements removed.
|
|
* @param array The array to remove duplicates from.
|
|
* @return A copy of the array with all duplicate elements removed.
|
|
*/
|
|
public static function unique<T>(array:Array<T>):Array<T>
|
|
{
|
|
var result:Array<T> = [];
|
|
for (element in array)
|
|
{
|
|
if (!result.contains(element))
|
|
{
|
|
result.push(element);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|