@@ -4,10 +4,10 @@ package bazaarbot.utils;
44 * A set of functions for array manipulation. (Copied from HaxeFlixel)
55 */
66class ArrayUtil
7- {
7+ {
88 /**
99 * Sets the length of an array.
10- *
10+ *
1111 * @param array The array.
1212 * @param newLength The length you want the array to have.
1313 */
@@ -30,12 +30,12 @@ class ArrayUtil
3030 #end
3131 }
3232 }
33-
33+
3434 /**
3535 * Safely removes an element from an array by swapping it with the last element and calling pop()
36- * (won't do anything if the element is not in the array). This is a lot faster than regular splice(),
36+ * (won't do anything if the element is not in the array). This is a lot faster than regular splice(),
3737 * but it can only be used on arrays where order doesn't matter.
38- *
38+ *
3939 * @param array The array to remove the element from
4040 * @param element The element to remove from the array
4141 * @return The array
@@ -50,13 +50,13 @@ class ArrayUtil
5050 }
5151 return array ;
5252 }
53-
53+
5454 /**
5555 * Removes an element from an array by swapping it with the last element and calling pop().
5656 * This is a lot faster than regular splice(), but it can only be used on arrays where order doesn't matter.
57- *
57+ *
5858 * IMPORTANT: always count down from length to zero if removing elements from whithin a loop
59- *
59+ *
6060 * var i = array.length;
6161 * while (i-- > 0)
6262 * {
@@ -65,7 +65,7 @@ class ArrayUtil
6565 * ArrayUtil.swapAndPop(array, i);
6666 * }
6767 * }
68- *
68+ *
6969 * @param array The array to remove the element from
7070 * @param index The index of the element to be removed from the array
7171 * @return The array
@@ -77,7 +77,7 @@ class ArrayUtil
7777 array .pop ();
7878 return array ;
7979 }
80-
80+
8181 /**
8282 * Clears an array structure, but leaves the object data untouched
8383 * Useful for cleaning up temporary references to data you want to preserve
@@ -110,7 +110,7 @@ class ArrayUtil
110110 }
111111 }
112112 }
113-
113+
114114 /**
115115 * Flattens 2D arrays into 1D arrays.
116116 * Example: [[1, 2], [3, 2], [1, 1]] -> [1, 2, 3, 2, 1, 1]
@@ -119,15 +119,15 @@ class ArrayUtil
119119 public static function flatten2DArray <T >(array : Array <Array <T >>): Array <T >
120120 {
121121 var result = [];
122-
122+
123123 for (innerArray in array )
124124 {
125125 result = result .concat (innerArray );
126126 }
127-
127+
128128 return result ;
129129 }
130-
130+
131131 /**
132132 * Compares the contents with == to see if the two arrays are the same.
133133 * Also takes null arrays and the length of the arrays into account.
@@ -142,7 +142,7 @@ class ArrayUtil
142142 return false ;
143143 if (array1 .length != array2 .length )
144144 return false ;
145-
145+
146146 for (i in 0 ... array1 .length )
147147 {
148148 if (array1 [i ] != array2 [i ])
@@ -152,7 +152,7 @@ class ArrayUtil
152152 }
153153 return true ;
154154 }
155-
155+
156156 /**
157157 * Returns the last element of an array or null if the array is null / empty.
158158 */
@@ -162,4 +162,4 @@ class ArrayUtil
162162 return null ;
163163 return array [array .length - 1 ];
164164 }
165- }
165+ }
0 commit comments