| Package | com.rubenswieringa.utils |
| Class | public class ArrayTool |
See also
| Method | Defined by | ||
|---|---|---|---|
|
adjustValues(array:Array, value:*, operator:String = "*"):Array
[static]
Adjusts all values in an Array.
| ArrayTool | ||
|
copy(source:Array):Array
[static]
Returns a shallow copy of an Array.
| ArrayTool | ||
|
getValueMatchIndex(array:Array, property:*, value:*):int
[static]
Similar to ArrayUtil.getItemIndex(), this method searches an Array for an Object with a given property that has a certain value.
| ArrayTool | ||
| adjustValues | () | method |
public static function adjustValues(array:Array, value:*, operator:String = "*"):ArrayAdjusts all values in an Array.
Parametersarray:Array — Array whose values to adjust
|
|
value:* — Value with which to increase, decrease, multiply, or divide a value from array with
|
|
operator:String (default = "*") — Indicates how to adjust a value from array (addition, minus, multiplication, or division)
|
Array — Array with adjusted values
|
See also
| copy | () | method |
public static function copy(source:Array):ArrayReturns a shallow copy of an Array.
Parameterssource:Array — Array to be copied.
|
Array |
See also
| getValueMatchIndex | () | method |
public static function getValueMatchIndex(array:Array, property:*, value:*):int
Similar to ArrayUtil.getItemIndex(), this method searches an Array for an Object with a given property that has a certain value. Can also search for nested Objects.
array:Array — Array to search.
|
|
property:* — Property or property-chain to try every item in the Array for. This parameter can either be a String (normal property), Array (property-chain), or numeric value (array index).
|
|
value:* — Value to be found.
|
int — Index of the item where the value was found on the end of the property chain.
|
var array:Array = [ {foo: {bar: 'value1'}}, {foo: {bar: 'value2'}}, {foo: {bar: 'value3'}} ];
var propChain:Array = ['foo', 'bar'];
var value:String = 'value3';
ArrayTool.getValueMatchIndex (array, propChain, value); // outputs 2