Class org.as2lib.data.holder.list.ArrayList

Implemented Interfaces

List

Description

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
 

Method Index

new ArrayList()
clear(), get(), insertByIndexAndValue(), iterator(), removeByIndex(), set(), size(), toArray()

Inherited from AbstractList

Constructor Detail

ArrayList

public function ArrayList(source:Array)

Constructs a new ArrayList instance.

Parameters

source(optional) an array that contains values to populate this new list with

Method Detail

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

Specified By

insertByIndexAndValue() in org.as2lib.data.holder.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

Specified By

removeByIndex() in org.as2lib.data.holder.List

set

public function set(index:Number, value)

Sets value to given index on this list.

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

Specified By

set() in org.as2lib.data.holder.List

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

Specified By

get() in org.as2lib.data.holder.List

clear

public function clear(Void):Void

Removes all values from this list.

Specified By

clear() in org.as2lib.data.holder.List

size

public function size(Void):Number

Returns the number of added values.

Return

the number of added values

Specified By

size() in org.as2lib.data.holder.List

iterator

public function iterator(Void):Iterator

Returns the iterator to iterate over this list.

Return

the iterator to iterate over this list

Specified By

iterator() in org.as2lib.data.holder.List

toArray

public function toArray(Void):Array

Returns the array representation of this list.

Return

the array representation of this list

Specified By

toArray() in org.as2lib.data.holder.List