class flixel.util.FlxArrayUtil

Available on all platforms

A set of functions for array manipulation.

Class Fields

static function clearArray<T>(array:Array<T>, ?recursive:Bool = false):Void

Clears an array structure, but leaves the object data untouched * Useful for cleaning up temporary references to data you want to preserve * WARNING: Can lead to memory leaks. Use destroyArray() instead for data you truly want GONE. * *

array

The array to clear out *

Recursive

Whether to search for arrays inside of arr and clear them out, too (false by default)

static function clearArray_clearArray_T(array:Array<T>, ?recursive:Bool):Void

static function clearArray_flixel_group_FlxTypedGroup_T(array:Array<T>, ?recursive:Bool = false):Void

static function clearArray_flixel_input_FlxSwipe(array:Array<FlxSwipe>, ?recursive:Bool = false):Void

static function clearArray_flixel_util_FlxPath(array:Array<FlxPath>, ?recursive:Bool = false):Void

static function clearArray_flixel_util_FlxTimer(array:Array<FlxTimer>, ?recursive:Bool = false):Void

static function fastSplice<T>(array:Array<T>, element:T):Array<T>

Safely removes an element from an array by swapping it with the last element and calling pop() * (won't do anything if the element is not in the array). This is a lot faster than regular splice(), * but it can only be used on arrays where order doesn't matter. * *

array

The array to remove the element from *

element

The element to remove from the array *

returns

The array

static function getRandom<T>(Objects:Array<T>, ?StartIndex:Int = 0, ?EndIndex:Int = 0):T

Deprecated; please use FlxRandom.getObject() instead. * Fetch a random entry from the given array from StartIndex to EndIndex. * *

Objects

An array from which to select a random entry. *

StartIndex

Optional index from which to restrict selection. Default value is 0, or the beginning of the array. *

EndIndex

Optional index at which to restrict selection. Ignored if 0, which is the default value. *

returns

The random object that was selected.

static function getRandom_flixel_group_FlxTypedGroup_T(Objects:Array<T>, ?StartIndex:Int = 0, ?EndIndex:Int = 0):T

static function indexOf<T>(array:Array<T>, whatToFind:T, ?fromIndex:Int = 0):Int

Function to search for a specified element in an array. This is faster than Lambda.indexOf() * on the flash target because it uses the the native array indexOf() method. * *

array

The array. *

whatToFind

The element you're looking for. *

fromIndex

The index to start the search from (optional, for optimization). *

returns

The index of the element within the array. -1 if it wasn't found.

static function indexOf_Float(array:Array<Float>, whatToFind:Float, ?fromIndex:Int = 0):Int

static function indexOf_Int(array:Array<Int>, whatToFind:Int, ?fromIndex:Int = 0):Int

static function indexOf_String(array:Array<String>, whatToFind:String, ?fromIndex:Int = 0):Int

static function indexOf_fastSplice_T(array:Array<T>, whatToFind:T, ?fromIndex:Int = 0):Int

static function indexOf_flixel_group_FlxTypedGroup_T(array:Array<T>, whatToFind:T, ?fromIndex:Int = 0):Int

static function indexOf_flixel_system_debug_WatchEntry(array:Array<WatchEntry>, whatToFind:WatchEntry, ?fromIndex:Int = 0):Int

static function indexOf_flixel_system_layer_frames_FlxFrame(array:Array<FlxFrame>, whatToFind:FlxFrame, ?fromIndex:Int = 0):Int

static function indexOf_flixel_system_ui_FlxSystemButton(array:Array<FlxSystemButton>, whatToFind:FlxSystemButton, ?fromIndex:Int = 0):Int

static function indexOf_flixel_util_FlxPath(array:Array<FlxPath>, whatToFind:FlxPath, ?fromIndex:Int = 0):Int

static function indexOf_flixel_util_FlxPoint(array:Array<FlxPoint>, whatToFind:FlxPoint, ?fromIndex:Int = 0):Int

static function indexOf_flixel_util_FlxPool_T(array:Array<T>, whatToFind:T, ?fromIndex:Int = 0):Int

static function setLength<T>(array:Array<T>, newLength:Int):Void

Sets the length of an array. * *

array

The array. *

newLength

The length you want the array to have.

static function setLength_Int(array:Array<Int>, newLength:Int):Void

static function setLength_flash_geom_Rectangle(array:Array<Rectangle>, newLength:Int):Void

static function setLength_flixel_group_FlxTypedGroup_T(array:Array<T>, newLength:Int):Void

static function setLength_flixel_input_keyboard_FlxKey(array:Array<FlxKey>, newLength:Int):Void

static function shuffle<T>(Objects:Array<T>, HowManyTimes:Int):Array<T>

Deprecated; please use FlxRandom.shuffleArray() instead. * Shuffles the entries in an array into a new random order. * *

Objects

An array to shuffle. *

HowManyTimes

How many swaps to perform during the shuffle operation. A good rule of thumb is 2-4 times the number of objects in the list. *

returns

The newly shuffled array.

static function swapAndPop<T>(array:Array<T>, index:Int):Array<T>

Removes an element from an array by swapping it with the last element and calling pop(). * This is a lot faster than regular splice(), but it can only be used on arrays where order doesn't matter. * * IMPORTANT: always count down from length to zero if removing elements from whithin a loop * * var i = array.length; * while (i-- > 0) * { * if (array[i].shouldRemove) * { * FlxArrayUtil.swapAndPop(array, i); * } * } * *

array

The array to remove the element from *

index

The index of the element to be removed from the array *

returns

The array

static function swapAndPop_fastSplice_T(array:Array<T>, index:Int):Array<T>