ArrayUtils

Kind of class:class
Inherits from:none
Author:Martijn de Visser, Arthur Clemens
Classpath:org.asapframework.util.ArrayUtils
File last modified:Thursday, 12 October 2006, 11:19:40
A collection of Array utility functions.

Summary


Class methods
  • findElement (inList:Array, inValue:Object) : Number
    • Searches array for an element with a specific value.
  • removeElement (inList:Array, inValue:Object) : Boolean
    • Searches array for an element with a specific value.
  • insertElementAt (inList:Array, inPosition:Number, inValue:Object) : Boolean
    • Inserts an element in an array at the specified position.
  • findProperty (inList:Array, inProp:String, inValue:Object, inStart:Number) : Number
    • Searches array of objects for an object with a specific property, also checks if the property has the correct value (if specified in "value").
  • randomize (inList:Array) : Void
    • Randomizes an array.
  • copy (inList:Array) : Array
    • Copies an array.

Class methods

copy

static function copy (
inList:Array) : Array

Copies an array.
Parameters:
inList:
the array to copy
Example:
  • var myCopyList:Array = ArrayUtils.copy(myOriginalList);

findElement

static function findElement (
inList:Array, inValue:Object) : Number

Searches array for an element with a specific value.
Parameters:
inList :
array to perform search on.
inValue:
(generically typed) value to search for in List elements.
Returns:
  • The index of the found element; -1 if not found.

findProperty

static function findProperty (
inList:Array, inProp:String, inValue:Object, inStart:Number) : Number

Searches array of objects for an object with a specific property, also checks if the property has the correct value (if specified in "value"). Pass the start value if you want this function to begin searching at a specific index
Parameters:
inList :
array to perform search on.
inProp :
the object property to search for
inValue:
(generically typed) value to test the contents of found Prop against.
inStart:
index position to start the search from
Returns:
  • Index position of the found element; -1 if not found.

insertElementAt

static function insertElementAt (
inList:Array, inPosition:Number, inValue:Object) : Boolean

Inserts an element in an array at the specified position. Fails if position is out of bounds.
Parameters:
inList :
array to perform insertion on.
inPosition:
the position to insert element at (zero-based).
inValue :
(generically typed) element to insert.
Returns:
  • Boolean indicating successfull insertion.

randomize

static function randomize (
inList:Array) : Void

Randomizes an array. Performs the operation directly on the passed array, so does not return a new array.
Parameters:
inList:
the array to randomize
Implementation note:
Example:
  • ArrayUtils.randomize(myList);
    var o:Object = myList[0];
    // etcetera

removeElement

static function removeElement (
inList:Array, inValue:Object) : Boolean

Searches array for an element with a specific value.
Parameters:
inList :
array to perform search on.
inValue:
(generically typed) value to search for in List elements.
Returns:
  • Boolean indicating successfull removal.