ArrayUtil
| Kind of class: | class |
|---|---|
| Inherits from: | BasicClass |
| Author: | Simon Wacker, Martin Heidegger, Christophe Herreman |
| Classpath: | org.as2lib.util.ArrayUtil |
| File last modified: | Wednesday, 14 September 2005, 20:51:26 |
ArrayUtil contains fundamental methods to manipulate Arrays.Summary
Class methods
Instance methods
Instance methods inherited from BasicClass
Class methods
clone
static function clone (
array:Array) : Array
Clones an array.
Parameters:
array:
the array to clone
Returns:
a clone of the passed-in
arraycontains
static function contains (
array:Array,
object) : Boolean
Checks if the passed-in
array contains the given object.The content is searched through with a for..in loop. This enables any type of
array to be passed-in, indexed and associative arrays.
Parameters:
array :
the array that may contain the
objectobject:
the object that may be contained in the
arrayReturns:
true if the array contains the object elsefalseindexOf
static function indexOf (
array:Array,
object) : Number
Returns the index of first occurance of the given
the passed-in
object withinthe passed-in
array.The content of the array is searched through by iterating through the
array. This method returns the first occurence of the passed-in object
within the array. If the object could not be found -1 will be
returned.
Parameters:
array :
the array to search through
object:
the object to return the position of
Returns:
the position of the
object within the array or -1isSame
static function isSame (
array1:Array,
array2:Array) : Boolean
Compares the two arrays
the same values at the same positions.
array1 and array2, whether they containthe same values at the same positions.
Parameters:
array1:
the first array for the comparison
array2:
the second array for the comparison
Returns:
positions else
true if the two arrays contain the same values at the samepositions else
falselastIndexOf
static function lastIndexOf (
array:Array,
object) : Number
Returns the index of the last occurance of the given
the passed-in
object withinthe passed-in
array.The content of the array is searched through by iterating through the
array. This method returns the last occurence of the passed-in object
within the array. If the object could not be found -1 will be
returned.
Parameters:
array :
the array to search through
object:
the object to return the position of
Returns:
the position of the
object within the array or -1removeAllOccurances
static function removeAllOccurances (
array:Array,
element) : Array
Removes all occurances of a the given
element out of the passed-inarray.Parameters:
array :
the array to remove the element out of
element:
the element to remove
Returns:
List that contains the index of all removed occurances
removeElement
static function removeElement (
array:Array,
element) : Array
Removes the given
element out of the passed-in array.Parameters:
array :
the array to remove the element out of
element:
the element to remove
Returns:
not contained in the passed-in
true if element was removed and false if it wasnot contained in the passed-in
arrayremoveFirstOccurance
static function removeFirstOccurance (
array:Array,
element) : Number
Removes the first occurance of the given
element out of the passed-inarray.Parameters:
array :
the array to remove the element out of
element:
the element to remove
Returns:
-1 if it could not be found, else the position where it had been deletedremoveLastOccurance
static function removeLastOccurance (
array:Array,
element) : Number
Removes the last occurance of the given
element out of the passed-inarray.Parameters:
array :
the array to remove the element out of
element:
the element to remove
Returns:
-1 if it could not be found, else the position where it had been deletedshuffle
static function shuffle (
array:Array) : Void
Shuffles the passed-in
array.Parameters:
array:
the array to shuffle
swap
static function swap (
array:Array,
i:Number,
j:Number) : Array
Swaps the value at position
passed-in
i with the value at position j of thepassed-in
array.The modifications are directly made to the passed-in array.
Parameters:
array:
the array whose elements to swap
i :
the index of the first value
j :
the index of the second value
Returns:
array the passed-in
arrayThrows:
org.as2lib.env.except.IllegalArgumentException if the argument
org.as2lib.data.holder.NoSuchElementException if the passed-in positions
are less than 0 or greater than the array's length
array is nullorg.as2lib.data.holder.NoSuchElementException if the passed-in positions
i and jare less than 0 or greater than the array's length