List
ArrayList
is a resizable-array implementation of List
interface.
Example:
var list:List = new ArrayList();
list.insert("myValue1");
list.insertFirst("myValue2");
list.insertLast("myValue3");
trace(list.contains("myValue2"));
trace(list.remove(0));
trace(list.contains("myValue2"));
trace(list.removeLast());
trace(list.get(0));
list.clear();
trace(list.size());
Output:
true myValue2 false myValue3 myValue1 0
new ArrayList()
public function insertByIndexAndValue(index:Number, value):Void
Inserts value
at the given index
.
The element that is currently at the given index
is shifted by one to
the right, as well as any subsequent elements.
index | the index at which to insert the value
|
value | the value to insert |
IndexOutOfBoundsException | if the given index is not in range,
this is less than 0 or greater than this list's size
|
public function removeByIndex(index:Number)
Removes the value at given index
from this list and returns it.
index | the index of the value to remove |
the removed value that was originally at given index
IndexOutOfBoundsException | if given index is less than 0 or
equal to or greater than this list's size
|
public function set(index:Number, value)
Sets value
to given index
on this list.
index | the index of value
|
value | the value to set to given index
|
the value that was orignially at given index
IndexOutOfBoundsException | if given index is less than 0 or
equal to or greater than this list's size
|
public function get(index:Number)
Returns the value at given index
.
index | the index to return the value of |
the value that is at given index
IndexOutOfBoundsException | if given index is less than 0 or
equal to or greater than this list's size
|
public function size(Void):Number
Returns the number of added values.
the number of added values
public function iterator(Void):Iterator
Returns the iterator to iterate over this list.
the iterator to iterate over this list