Utility methods for working with arrays.
public function Arrays()
Constructor, throws an error if called, as this is an abstract class.
public static function binarySearch(a:Array, key:Object, prop:String = null, cmp:Function = null):int
Performs a binary search over the input array for the given key
value, optionally using a provided property to extract from array
items and a custom comparison function.
Parameters
| a:Array — the array to search over
|
| |
| key:Object — the key value to search for
|
| |
| prop:String (default = null) — the property to retrieve from objecs in the array. If null
(the default) the array values will be used directly.
|
| |
| cmp:Function (default = null) — an optional comparison function
|
Returns
| int — the index of the given key if it exists in the array,
otherwise -1 times the index value at the insertion point that
would be used if the key were added to the array.
|
public static function clear(a:Array):void
Clears an array instance, removing all values.
Parameters
| a:Array — the array to clear
|
public static function copy(a:Array, b:Array = null, a0:int = 0, b0:int = 0, len:int = -1):Array
Makes a copy of an array or copies the contents of one array to
another.
Parameters
| a:Array — the array to copy
|
| |
| b:Array (default = null) — the array to copy values to. If null, a new array is
created.
|
| |
| a0:int (default = 0) — the starting index from which to copy values
of the input array
|
| |
| b0:int (default = 0) — the starting index at which to write value into the
output array
|
| |
| len:int (default = -1) — the number of values to copy
|
Returns
| Array — the target array containing the copied values
|
public static function fill(a:Array, o:*):void
Fills an array with a given value.
Parameters
| a:Array — the array
|
| |
| o:* — the value with which to fill the array
|
public static function max(a:Array, p:Property = null):Number
Returns the maximum value in an array. Comparison is determined
using the greater-than operator against arbitrary types.
Parameters
| a:Array — the array
|
| |
| p:Property (default = null) — an optional property from which to extract the value.
If this is null, the immediate contents of the array are compared.
|
Returns
| Number — the maximum value
|
public static function maxIndex(a:Array, p:Property = null):Number
Returns the index of a maximum value in an array. Comparison is
determined using the greater-than operator against arbitrary types.
Parameters
| a:Array — the array
|
| |
| p:Property (default = null) — an optional property from which to extract the value.
If this is null, the immediate contents of the array are compared.
|
Returns
| Number — the index of a maximum value
|
public static function min(a:Array, p:Property = null):Number
Returns the minimum value in an array. Comparison is determined
using the less-than operator against arbitrary types.
Parameters
| a:Array — the array
|
| |
| p:Property (default = null) — an optional property from which to extract the value.
If this is null, the immediate contents of the array are compared.
|
Returns
| Number — the minimum value
|
public static function minIndex(a:Array, p:Property = null):Number
Returns the index of a minimum value in an array. Comparison is
determined using the less-than operator against arbitrary types.
Parameters
| a:Array — the array
|
| |
| p:Property (default = null) — an optional property from which to extract the value.
If this is null, the immediate contents of the array are compared.
|
Returns
| Number — the index of a minimum value
|
public static function remove(a:Array, o:Object):int
Removes an element from an array. Only the first instance of the
value is removed.
Parameters
| a:Array — the array
|
| |
| o:Object — the value to remove
|
Returns
| int — the index location at which the removed element was found,
negative if the value was not found.
|
public static function removeAt(a:Array, idx:uint):Object
Removes the array element at the given index.
Parameters
| a:Array — the array
|
| |
| idx:uint — the index at which to remove an element
|
Returns
| Object — the removed element
|
public static function setProperty(a:Array, name:String, value:Function, filter:IValueProxy, p:* = null):void
Sets a named property value for items stored in an array.
The value can take a number of forms:
- If the value is a
Function, it will be evaluated
for each element and the result will be used as the property
value for that element.
- If the value is an
IEvaluable instance, it will be
evaluated for each element and the result will be used as the
property value for that element.
- In all other cases, the property value will be treated as a
literal and assigned for all elements.
Parameters
| a:Array — the array to set property values for
|
| |
| name:String — the name of the property to set
|
| |
| value:Function — the value of the property to set
|
| |
| filter:IValueProxy — a filter function determining which items
in the array should be processed
|
| |
| p:* (default = null) — an optional IValueProxy for setting the values
|
public static const EMPTY:Array