Interface org.as2lib.data.holder.List

org.as2lib.core.BasicInterface
   +--org.as2lib.data.holder.List

Description

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
 

Method Index

clear(), contains(), containsAll(), get(), indexOf(), insert(), insertAll(), insertAllByIndexAndList(), insertAllByList(), insertByIndexAndValue(), insertByValue(), insertFirst(), insertLast(), isEmpty(), iterator(), remove(), removeAll(), removeByIndex(), removeByValue(), removeFirst(), removeLast(), retainAll(), set(), setAll(), size(), subList(), toArray()

Inherited from BasicInterface

toString()

Method Detail

insert

public function insert():Void

insertByValue

public function insertByValue(value):Void

Inserts value at the end of this list.

Parameters

valuethe value to insert

insertByIndexAndValue

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.

Parameters

indexthe index at which to insert the value
valuethe value to insert

Throws

IndexOutOfBoundsExceptionif the given index is not in range, this is less than 0 or greater than this list's size

insertFirst

public function insertFirst(value):Void

Inserts value at the beginning of this list.

Parameters

valuethe value to insert

insertLast

public function insertLast(value):Void

Inserts value at the end of this list.

Parameters

valuethe value to insert

insertAll

public function insertAll():Void

insertAllByList

public function insertAllByList(list:List):Void

Inserts all values contained in list to the end of this list.

Parameters

listthe values to insert

insertAllByIndexAndList

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.

Parameters

indexthe index to start the insertion at
listthe values to insert

Throws

IndexOutOfBoundsExceptionif the given index is not in range, this is less than 0 or greater than this list's size

remove

public function remove()

removeByValue

public function removeByValue(value):Number

Removes value from this list if it exists and returns the index of the removed element.

Parameters

valuethe value to remove

Return

the index of the removed element or -1 if it did not exist on this list

removeByIndex

public function removeByIndex(index:Number)

Removes the value at given index from this list and returns it.

Parameters

indexthe index of the value to remove

Return

the removed value that was originally at given index

Throws

IndexOutOfBoundsExceptionif given index is less than 0 or equal to or greater than this list's size

removeFirst

public function removeFirst(Void)

Removes the value at the beginning of this list.

Return

the removed value

removeLast

public function removeLast(Void)

Removes the value at the end of this list.

Return

the removed value

removeAll

public function removeAll(list:List):Void

Removes all values contained in list.

Parameters

listthe values to remove

set

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.

Parameters

indexthe index of value
valuethe value to set to given index

Return

the value that was orignially at given index

Throws

IndexOutOfBoundsExceptionif given index is less than 0 or equal to or greater than this list's size

setAll

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.

Parameters

indexthe index to start at
listthe values to set

Throws

IndexOutOfBoundsExceptionif 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

get

public function get(index:Number)

Returns the value at given index.

Parameters

indexthe index to return the value of

Return

the value that is at given index

Throws

IndexOutOfBoundsExceptionif given index is less than 0 or equal to or greater than this list's size

contains

public function contains(value):Boolean

Checks whether value is contained in this list.

Parameters

valuethe value to check whether it is contained

Return

true if value is contained else false

containsAll

public function containsAll(list:List):Boolean

Checks whether all values of list are contained in this list.

Parameters

listthe values to check whether they are contained

Return

true if all values of list are contained else false

retainAll

public function retainAll(list:List):Void

Retains all values the are contained in list and removes all others.

Parameters

listthe list of values to retain

subList

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.

Parameters

fromIndexthe index from which the sub-list starts (inclusive)
toIndexthe index specifying the end of the sub-list (exclusive)

Return

a view of the specified range within this list

Throws

IndexOutOfBoundsExceptionif argument fromIndex is less than 0
IndexOutOfBoundsExceptionif argument toIndex is greater than the size of this list
IndexOutOfBoundsExceptionif argument fromIndex is greater than toIndex

clear

public function clear(Void):Void

Removes all values from this list.

size

public function size(Void):Number

Returns the number of added values.

Return

the number of added values

isEmpty

public function isEmpty(Void):Boolean

Returns whether this list is empty.

This list is empty if it has no values assigned to it.

Return

true if this list is empty else false

iterator

public function iterator(Void):Iterator

Returns the iterator to iterate over this list.

Return

the iterator to iterate over this list

indexOf

public function indexOf(value):Number

Returns the index of value.

Parameters

valuethe value to return the index of

Return

the index of value

toArray

public function toArray(Void):Array

Returns the array representation of this list.

Return

the array representation of this list