Packageas3.collections
Classpublic class ArrayList
ImplementsIArrayList
SubclassesArrayListFx

List based on an array and providing indexed access to its items.

Can be considered as an ordinary Array wrapper.

Runtime of operations



Public Properties
 PropertyDefined by
  numItems : uint
[read-only] Returns the size of the collection.
ArrayList
Protected Properties
 PropertyDefined by
  _array : Array
The array.
ArrayList
Public Methods
 MethodDefined by
  
Creates a new ArrayList.
ArrayList
  
addItem(item:*):Boolean
Adds an item to the list, usually at the end.
ArrayList
  
addItemAt(index:uint, item:*):uint
Adds an item at a specific position.
ArrayList
  
addItemAtEnd(item:*):uint
Adds an item at the end of the list.
ArrayList
  
addItemAtStart(item:*):uint
Adds an item in front of the list.
ArrayList
  
addItemsAt(index:uint, items:Array):uint
Adds an array of items at a specific position.
ArrayList
  
clear():void
Removes all items from the collection.
ArrayList
  
countItems(item:*):uint
Returns the number of occurrences of an item.
ArrayList
  
getFirstIndexOf(item:*):int
Returns the index of the first occurrence of an item.
ArrayList
  
Returns the first item of the sequence.
ArrayList
  
getItemAt(index:uint):*
Returns the item at the specified position.
ArrayList
  
getIterator(cursor:uint = 0):IIterator
Returns an iterator over the list items starting at the specified position.
ArrayList
  
Returns the last item of the sequence.
ArrayList
  
hasItem(item:*):Boolean
Tests, if an item is contained by the list.
ArrayList
  
removeAll(item:*):uint
Removes all occurrences of a particular item from the list.
ArrayList
  
Removes the first item of the sequence.
ArrayList
  
removeItem(item:*):Boolean
Removes an item from the list.
ArrayList
  
removeItemAt(index:uint):*
Removes an item at the specified position.
ArrayList
  
removeItemsAt(index:uint, numItems:uint):Array
Removes a number of items starting at the specified position.
ArrayList
  
Removes the last item of the sequence.
ArrayList
  
replaceItemAt(index:uint, item:*):Boolean
Replaces the item at the specified position.
ArrayList
  
reverse():void
Reverses the list order.
ArrayList
  
setArray(array:Array):void
Specifies an array to be maintained by the list.
ArrayList
  
sort(comparator:IComparator):void
Sorts the list by the given criterion.
ArrayList
  
toArray():Array
Returns an array of all items in the order of the particular collection.
ArrayList
  
toString():String
Info
ArrayList
Protected Methods
 MethodDefined by
  
itemRemoved(item:*, index:uint):void
Template method to notify subclasses after an item has been removed.
ArrayList
Property detail
_arrayproperty
protected var _array:Array

The array.

numItemsproperty 
numItems:uint  [read-only]

Returns the size of the collection.

Implementation
    public function get numItems():uint
Constructor detail
ArrayList()constructor
public function ArrayList()

Creates a new ArrayList.

Method detail
addItem()method
public function addItem(item:*):Boolean

Adds an item to the list, usually at the end.

Parameters
item:* — The item.

Returns
Boolean — true, if the item has been added, else false.
addItemAt()method 
public function addItemAt(index:uint, item:*):uint

Adds an item at a specific position.

If the given position exceeds the array length, the item will be appended.

Parameters
index:uint — The position of the new item.
 
item:* — The item.

Returns
uint — The index of the just added item.
addItemAtEnd()method 
public function addItemAtEnd(item:*):uint

Adds an item at the end of the list.

Parameters
item:* — The item.

Returns
uint — list.numItems - 1.
addItemAtStart()method 
public function addItemAtStart(item:*):uint

Adds an item in front of the list.

Parameters
item:* — The item.

Returns
uint — 0.
addItemsAt()method 
public function addItemsAt(index:uint, items:Array):uint

Adds an array of items at a specific position.

If the given position exceeds the array length, the items will be appended.

Parameters
index:uint — The position of the first new item.
 
items:Array — An array of items to add.

Returns
uint — The index where the items have been added.
clear()method 
public function clear():void

Removes all items from the collection.

countItems()method 
public function countItems(item:*):uint

Returns the number of occurrences of an item.

Parameters
item:*

Returns
uint — Number of occurrences of the given item.
getFirstIndexOf()method 
public function getFirstIndexOf(item:*):int

Returns the index of the first occurrence of an item.

Parameters
item:* — The item to test.

Returns
int — The item's first position or -1, if the item is not contained.
getFirstItem()method 
public function getFirstItem():*

Returns the first item of the sequence.

Returns
* — The first item or undefined, if the list is empty.
getItemAt()method 
public function getItemAt(index:uint):*

Returns the item at the specified position.

Parameters
index:uint — The position of the item to get.

Returns
* — The item or undefined, if the position is invalid.
getIterator()method 
public function getIterator(cursor:uint = 0):IIterator

Returns an iterator over the list items starting at the specified position.

Costs and order same as for the ArrayIterator.

Parameters
cursor:uint (default = 0) — The start position.

Returns
IIterator — The iterator.

See also

getLastItem()method 
public function getLastItem():*

Returns the last item of the sequence.

Returns
* — The last item or undefined, if the list is empty.
hasItem()method 
public function hasItem(item:*):Boolean

Tests, if an item is contained by the list.

Parameters
item:* — The item to test.

Returns
Boolean — true, if the item is contained, else false.
itemRemoved()method 
protected function itemRemoved(item:*, index:uint):void

Template method to notify subclasses after an item has been removed.

Parameters
item:* — The removed item.
 
index:uint — The former index of the removed item.
removeAll()method 
public function removeAll(item:*):uint

Removes all occurrences of a particular item from the list.

The items will be removed in the order they are stored.

Parameters
item:* — The item to remove completely.

Returns
uint — Number of items removed.
removeFirstItem()method 
public function removeFirstItem():*

Removes the first item of the sequence.

Returns
* — The first item or undefined, if the list is empty.
removeItem()method 
public function removeItem(item:*):Boolean

Removes an item from the list.

Parameters
item:* — The item to remove.

Returns
Boolean — true, if the item has been removed or false, if the given item is not contained by the list.
removeItemAt()method 
public function removeItemAt(index:uint):*

Removes an item at the specified position.

Parameters
index:uint — The position of the item to remove.

Returns
* — The removed item or undefined, if there is no item at that position.
removeItemsAt()method 
public function removeItemsAt(index:uint, numItems:uint):Array

Removes a number of items starting at the specified position.

Parameters
index:uint — The position of the first item to remove.
 
numItems:uint — The number of items to remove.

Returns
Array — An array of all removed items.
removeLastItem()method 
public function removeLastItem():*

Removes the last item of the sequence.

Returns
* — The last item or undefined, if the list is empty.
replaceItemAt()method 
public function replaceItemAt(index:uint, item:*):Boolean

Replaces the item at the specified position.

If the item at the position equals the given item or the index is invalid, this method returns false and leaves the list unchanged.

Parameters
index:uint — The position of the item to replace.
 
item:* — The replacing item.

Returns
Boolean — true, if the item at that position has been replaced..
reverse()method 
public function reverse():void

Reverses the list order.

setArray()method 
public function setArray(array:Array):void

Specifies an array to be maintained by the list.

Already contained elements will be removed.

Parameters
array:Array — The array.
sort()method 
public function sort(comparator:IComparator):void

Sorts the list by the given criterion.

Parameters
comparator:IComparator — The sort criterion.
toArray()method 
public function toArray():Array

Returns an array of all items in the order of the particular collection.

Returns
Array — The array.
toString()method 
public function toString():String

Info

Returns
String