org.as2lib.core.BasicInterface +--org.as2lib.data.holder.List
List
holds values by index. Each value has its unique index.
Example:
var list:List = new MyList();
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
public function insertByValue(value):Void
Inserts value
at the end of this list.
value | the value to insert |
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 insertFirst(value):Void
Inserts value
at the beginning of this list.
value | the value to insert |
public function insertLast(value):Void
Inserts value
at the end of this list.
value | the value to insert |
public function insertAllByList(list:List):Void
Inserts all values contained in list
to the end of this list.
list | the values to insert |
public function insertAllByIndexAndList(index:Number, list:List):Void
Inserts all values contained in list
to this list, starting at the
specified index
.
Elements that are at an affected index are shifted to the right by the size
of the given list
.
index | the index to start the insertion at |
list | the values 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 removeByValue(value):Number
Removes value
from this list if it exists and returns the index of the
removed element.
value | the value to remove |
the index of the removed element or -1
if it did not exist on
this list
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 removeFirst(Void)
Removes the value at the beginning of this list.
the removed value
public function removeLast(Void)
Removes the value at the end of this list.
the removed value
public function removeAll(list:List):Void
Removes all values contained in list
.
list | the values to remove |
public function set(index:Number, value)
Sets value
to given index
on this list. The value that was
originally at the given index
will be overwritten.
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 setAll(index:Number, list:List):Void
Sets all values contained in list
to this list, starting from given
index
. They values that were originally at the given index
and following indices will be overwritten.
This method only overwrites existing index-value pairs. If an affected index
is equal to or greater than this list's size, which would mean that this list's
size had to be expanded, an IndexOutOfBoundsException
will be thrown. In
such a case use the insertAll method instead, which expands this list
dynamically.
index | the index to start at |
list | the values to set |
IndexOutOfBoundsException | if given index is less than 0 or if
any affected index, that is the given index plus the index of the
specific value in the given list , is 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 contains(value):Boolean
Checks whether value
is contained in this list.
value | the value to check whether it is contained |
true
if value
is contained else false
public function containsAll(list:List):Boolean
Checks whether all values of list
are contained in this list.
list | the values to check whether they are contained |
true
if all values of list
are contained else
false
public function retainAll(list:List):Void
Retains all values the are contained in list
and removes all others.
list | the list of values to retain |
public function subList(fromIndex:Number, toIndex:Number):List
Returns a view of the portion of this list between the specified fromIndex
,
inclusive, and toIndex
, exclusive.
If fromIndex
and toIndex
are equal an empty list is returned.
The returned list is backed by this list, so changes in the returned list are reflected in this list, and vice-versa.
fromIndex | the index from which the sub-list starts (inclusive) |
toIndex | the index specifying the end of the sub-list (exclusive) |
a view of the specified range within this list
IndexOutOfBoundsException | if argument fromIndex is less than 0
|
IndexOutOfBoundsException | if argument toIndex is greater than
the size of this list
|
IndexOutOfBoundsException | if argument fromIndex is greater than
toIndex
|
public function size(Void):Number
Returns the number of added values.
the number of added values
public function isEmpty(Void):Boolean
Returns whether this list is empty.
This list is empty if it has no values assigned to it.
true
if this list is empty else false
public function iterator(Void):Iterator
Returns the iterator to iterate over this list.
the iterator to iterate over this list