Method | Defined by | ||
---|---|---|---|
ArrayUtil Static Constructor
| ArrayUtil | ||
asort(a:Array):Array
[static]
Return alphabetically sorted array.
| ArrayUtil | ||
compare(aA:Array, aB:Array, hasSameOrder:Boolean = false):Boolean
[static]
Compare two arrays to see if their values (and optionally order) are identical.
| ArrayUtil | ||
contains(a:Array, val:Object):Boolean
[static]
Determines if a value exists within the array.
| ArrayUtil | ||
copy(a:Array):Array
[static]
Create a non-unique copy of the array.
| ArrayUtil | ||
equals(arr1:Array, arr2:Array):Boolean
[static]
Test if two arrays are identical.
| ArrayUtil | ||
indexOf(arr:Array, element:*):Number
[static]
Wrapper for search.
| ArrayUtil | ||
insert(a:Array, element:Object, index:int):Array
[static]
Insert an element into array at a specific index.
| ArrayUtil | ||
lastIndexOf(a:Array, element:*):Number
[static]
Search an array for the last instance of a given element and return its index or
-1 . | ArrayUtil | ||
locatePropVal(a:Array, prop:String, val:Object, isCaseInsensitive:Boolean = false):Object
[static]
Search for a unique property/value match in an array of complex objects.
| ArrayUtil | ||
locatePropValIndex(a:Array, prop:String, val:Object, isCaseInsensitive:Boolean = false):Number
[static]
Search for a unique property/value match in an array of complex objects and return its index in the array.
| ArrayUtil | ||
matchValues(aA:Array, aB:Array):Boolean
[static]
Compare two arrays for a matching value.
| ArrayUtil | ||
max(a:Array):int
[static]
Return the array index of the maximum value in a numeric array.
| ArrayUtil | ||
maxVal(a:Array):Number
[static]
Return the maximum value in a numeric array.
| ArrayUtil | ||
merge(aA:Array, aB:Array):Array
[static]
Merge two arrays into one.
| ArrayUtil | ||
min(a:Array):int
[static]
Return the array index of the minimum value in a numeric array.
| ArrayUtil | ||
minVal(a:Array):Number
[static]
Return the minimum value in a numeric array.
| ArrayUtil | ||
nearestNeighbor(val:Number, range:Array, returnIndex:Boolean = false):Number
[static]
Locate and return the (lowest) nearest neighbor or matching value in a
NUMERIC sorted array of Numbers. | ArrayUtil | ||
remove(a:Array, element:Object):Array
[static]
Remove all instances of an element from an array.
| ArrayUtil | ||
removeDuplicate(a:Array):Array
[static]
Return array with duplicate entries removed.
| ArrayUtil | ||
search(a:Array, element:Object):Number
[static]
Search an array for the first instance of a given element and return its index or
-1 . | ArrayUtil | ||
shuffle(a:Array):void
[static]
Shuffle array items.
| ArrayUtil | ||
sliceAll(a:Array, startIndex:int = 0, endIndex:int = 0):Array
[static]
Unlike normal
Array.slice(), sliceAll includes the endIndex in the return Array. | ArrayUtil | ||
sliceByPropVal(a:Array, prop:String, val:Object, isCaseInsensitive:Boolean = false):Array
[static]
Return a new array sliced from the original array of complex objects based on a
prop /val match
| ArrayUtil | ||
swap(a:Array, nA:int, nB:int):Array
[static]
Swap two elements positions in an array
| ArrayUtil | ||
uniqueCopy(a:Array):Array
[static]
Create a new array that only contains unique instances of objects in the specified array.
| ArrayUtil |
ArrayUtil | () | constructor |
public function ArrayUtil()
ArrayUtil Static Constructor
asort | () | method |
public static function asort(a:Array):Array
Return alphabetically sorted array.
Parametersa:Array |
Array |
compare | () | method |
public static function compare(aA:Array, aB:Array, hasSameOrder:Boolean = false):Boolean
Compare two arrays to see if their values (and optionally order) are identical.
ParametersaA:Array — When false the arrays must only contain identical values, when true value & order must be identical.
|
|
aB:Array |
|
hasSameOrder:Boolean (default = false )
|
Boolean |
var a : Array = [ 5,4,3,2,1,'C','B','A' ]; var b : Array = [ 'A','B','C',1,2,3,4,5 ]; trace( "arrays (unordered) compare: " + ArrayUtil.compare( a, b ) ); // returns true trace( "arrays (ordered) compare: " + ArrayUtil.compare( a, b, true ) ); // returns false
contains | () | method |
public static function contains(a:Array, val:Object):Boolean
Determines if a value exists within the array.
Parametersa:Array |
|
val:Object |
Boolean |
copy | () | method |
public static function copy(a:Array):Array
Create a non-unique copy of the array.
Parametersa:Array — array to clone.
|
Array — Array new array with items that are references to the original array.
|
equals | () | method |
public static function equals(arr1:Array, arr2:Array):Boolean
Test if two arrays are identical.
Parametersarr1:Array |
|
arr2:Array |
Boolean |
indexOf | () | method |
public static function indexOf(arr:Array, element:*):Number
Wrapper for search.
Parametersarr:Array |
|
element:* |
Number |
See also
insert | () | method |
public static function insert(a:Array, element:Object, index:int):Array
Insert an element into array at a specific index.
Parametersa:Array |
|
element:Object |
|
index:int |
Array |
lastIndexOf | () | method |
public static function lastIndexOf(a:Array, element:*):Number
Search an array for the last instance of a given element and return its index or -1
.
a:Array |
|
element:* |
Number |
locatePropVal | () | method |
public static function locatePropVal(a:Array, prop:String, val:Object, isCaseInsensitive:Boolean = false):Object
Search for a unique property/value match in an array of complex objects.
Parametersa:Array — array of objects.
|
|
prop:String — array object property to locate.
|
|
val:Object — array object property value to match.
|
|
isCaseInsensitive:Boolean (default = false ) — define whether prop /val should be case-insensitive (use only if search val is String ).
|
Object — Object the first array object with the prop /val match.
|
locatePropValIndex | () | method |
public static function locatePropValIndex(a:Array, prop:String, val:Object, isCaseInsensitive:Boolean = false):Number
Search for a unique property/value match in an array of complex objects and return its index in the array.
Parametersa:Array — array of objects.
|
|
prop:String — array object property to locate.
|
|
val:Object — array object property value to match.
|
|
isCaseInsensitive:Boolean (default = false ) — define whether prop /val should be case-insensitive (use only if search val is String ).
|
Number — Number the index of the first array object with the prop /val match or -1 if no match was found.
|
matchValues | () | method |
public static function matchValues(aA:Array, aB:Array):Boolean
Compare two arrays for a matching value.
ParametersaA:Array |
|
aB:Array |
Boolean |
max | () | method |
public static function max(a:Array):int
Return the array index of the maximum value in a numeric array.
Parametersa:Array |
int |
maxVal | () | method |
public static function maxVal(a:Array):Number
Return the maximum value in a numeric array.
Parametersa:Array |
Number — Number maximum value
|
merge | () | method |
public static function merge(aA:Array, aB:Array):Array
Merge two arrays into one.
ParametersaA:Array |
|
aB:Array |
Array |
min | () | method |
public static function min(a:Array):int
Return the array index of the minimum value in a numeric array.
Parametersa:Array |
int |
minVal | () | method |
public static function minVal(a:Array):Number
Return the minimum value in a numeric array.
Parametersa:Array |
Number — Number minimum value (0 is returned with 0 length arrays)
|
nearestNeighbor | () | method |
public static function nearestNeighbor(val:Number, range:Array, returnIndex:Boolean = false):Number
Locate and return the (lowest) nearest neighbor or matching value in a NUMERIC
sorted array of Numbers.
val:Number — the value to find match or find nearst match of.
|
|
range:Array — of values in array.
|
|
returnIndex:Boolean (default = false ) — if true return the array index of the neighbor, if false return the value of the neighbor.
|
Number |
var a : Array = [1, 3, 5, 7, 9, 11]; var nearestLow : Number = ArrayUtil.nearestNeighbor(4, a); // returns 3 (value) var nearestHigh : Number = ArrayUtil.nearestNeighbor(4, a, true); // returns 1 (index)
remove | () | method |
public static function remove(a:Array, element:Object):Array
Remove all instances of an element from an array.
Parametersa:Array |
|
element:Object |
Array |
removeDuplicate | () | method |
public static function removeDuplicate(a:Array):Array
Return array with duplicate entries removed.
Parametersa:Array |
Array |
search | () | method |
public static function search(a:Array, element:Object):Number
Search an array for the first instance of a given element and return its index or -1
.
a:Array |
|
element:Object |
Number |
shuffle | () | method |
public static function shuffle(a:Array):void
Shuffle array items.
Parametersa:Array |
sliceAll | () | method |
public static function sliceAll(a:Array, startIndex:int = 0, endIndex:int = 0):Array
Unlike normal Array.slice(), sliceAll
includes the endIndex
in the return Array.
a:Array — source array
|
|
startIndex:int (default = 0 ) — A number specifying the index of the starting point for the slice. If startIndex is a negative number, the starting point begins at the end of the array, where -1 is the last element.
|
|
endIndex:int (default = 0 ) — A number specifying the index of the ending point for the slice. If you omit this parameter, the slice includes all elements from the starting point to the end of the array. If endIndex is a negative number, the ending point is specified from the end of the array, where -1 is the last element.
|
Array — An array that consists of a range of elements from the original array.
|
sliceByPropVal | () | method |
public static function sliceByPropVal(a:Array, prop:String, val:Object, isCaseInsensitive:Boolean = false):Array
Return a new array sliced from the original array of complex objects based on a prop
/val
match
a:Array — array of objects.
|
|
prop:String — array object property to locate.
|
|
val:Object — array object property value to match.
|
|
isCaseInsensitive:Boolean (default = false ) — define whether prop /val should be case-insensitive (use only if search val is String ).
|
Array — Array of objects that contain the prop /val match.
|
swap | () | method |
public static function swap(a:Array, nA:int, nB:int):Array
Swap two elements positions in an array
Parametersa:Array |
|
nA:int |
|
nB:int |
Array |
— on invalid array index
|
uniqueCopy | () | method |
public static function uniqueCopy(a:Array):Array
Create a new array that only contains unique instances of objects in the specified array. this can be used to remove duplication object instances from an array.
Parametersa:Array |
Array |