org.as2lib.core.BasicClass +--org.as2lib.util.ArrayUtil
ArrayUtil
contains fundamental methods to manipulate Array
s.
static public function clone(array:Array):Array
Clones an array.
array | the array to clone |
a clone of the passed-in array
static public function removeElement(array:Array, element):Boolean
Removes the given element
out of the passed-in array
.
array | the array to remove the element out of |
element | the element to remove |
true
if element
was removed and false
if it was
not contained in the passed-in array
static public function removeAllOccurances(array:Array, element):Boolean
Removes all occurances of a the given element
out of the passed-in
array
.
array | the array to remove the element out of |
element | the element to remove |
true
if element
was removed and false
if it was
not contained in the passed-in array
static public function removeLastOccurance(array:Array, element):Boolean
Removes the last occurance of the given element
out of the passed-in
array
.
array | the array to remove the element out of |
element | the element to remove |
true
if element
was removed and false
if it was
not contained in the passed-in array
static public function removeFirstOccurance(array:Array, element):Boolean
Removes the first occurance of the given element
out of the passed-in
array
.
array | the array to remove the element out of |
element | the element to remove |
true
if element
was removed and false
if it was
not contained in the passed-in array
static public 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.
array | the array that may contain the object
|
object | the object that may be contained in the array
|
true
if the array
contains the object
else
false
static public function indexOf(array:Array, object):Number
Returns the index of the given object
within the 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.
array | the array to search through |
object | the object to return the position of |
the position of the object
within the array
or -1
static public function shuffle(array:Array):Void
Shuffles the passed-in array
.
array | the array to shuffle |
static public function swap(array:Array, i:Number, j:Number):Array
Swaps the value at position i
with the value at position j
of the
passed-in array
.
The modifications are directly made to the passed-in array
.
array | the array whose elements to swap |
i | the index of the first value |
j | the index of the second value |
array the passed-in array
IllegalArgumentException | if the argument array is null
|
NoSuchElementException | if the passed-in positions i and j
are less than 0 or greater than the array's length
|
static public function isSame(array1:Array, array2:Array):Boolean
Compares the two arrays array1
and array2
, whether they contain
the same values at the same positions.
array1 | the first array for the comparison |
array2 | the second array for the comparison |
true
if the two arrays contain the same values at the same
positions else false