Packageflare.util
Classpublic class Arrays

Utility methods for working with arrays.



Public Methods
 MethodDefined by
  
Constructor, throws an error if called, as this is an abstract class.
Arrays
  
binarySearch(a:Array, key:Object, prop:String = null, cmp:Function = null):int
[static] 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.
Arrays
  
clear(a:Array):void
[static] Clears an array instance, removing all values.
Arrays
  
copy(a:Array, b:Array = null, a0:int = 0, b0:int = 0, len:int = -1):Array
[static] Makes a copy of an array or copies the contents of one array to another.
Arrays
  
fill(a:Array, o:*):void
[static] Fills an array with a given value.
Arrays
  
max(a:Array, p:Property = null):Number
[static] Returns the maximum value in an array.
Arrays
  
maxIndex(a:Array, p:Property = null):Number
[static] Returns the index of a maximum value in an array.
Arrays
  
min(a:Array, p:Property = null):Number
[static] Returns the minimum value in an array.
Arrays
  
minIndex(a:Array, p:Property = null):Number
[static] Returns the index of a minimum value in an array.
Arrays
  
remove(a:Array, o:Object):int
[static] Removes an element from an array.
Arrays
  
removeAt(a:Array, idx:uint):Object
[static] Removes the array element at the given index.
Arrays
  
setProperty(a:Array, name:String, value:Function, filter:IValueProxy, p:* = null):void
[static] Sets a named property value for items stored in an array.
Arrays
Public Constants
 ConstantDefined by
  EMPTY : Array
[static]
Arrays
Constructor detail
Arrays()constructor
public function Arrays()

Constructor, throws an error if called, as this is an abstract class.

Method detail
binarySearch()method
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.
clear()method 
public static function clear(a:Array):void

Clears an array instance, removing all values.

Parameters
a:Array — the array to clear
copy()method 
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
fill()method 
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
max()method 
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
maxIndex()method 
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
min()method 
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
minIndex()method 
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
remove()method 
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.
removeAt()method 
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
setProperty()method 
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:

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
Constant detail
EMPTYconstant
public static const EMPTY:Array