Packagech.capi.data
Classpublic class ArrayList
InheritanceArrayList Inheritance Object
Implements IList
Subclasses QueueList, StackList

Represents a IList using an Array to store the elements.



Public Properties
 PropertyDefined By
  length : int
[read-only] Defines the number of elements contained in the ArrayList.
ArrayList
Public Methods
 MethodDefined By
  
ArrayList(initialData:Array = null)
Creates a new ArrayList object.
ArrayList
  
addElement(element:*):void
Add an element in the ArrayList.
ArrayList
  
addElementAt(element:*, index:int):void
Add an element in the ArrayList at the specified index.
ArrayList
  
clear():void
Removes all the elements contained in this ArrayList.
ArrayList
  
contains(element:*, compare:Function = null):Boolean
Returns true if the specified element is contained in the IList or false otherwise.
ArrayList
  
getElementAt(index:int):*
Get the element at the specified index.
ArrayList
  
getElementIndex(element:*):int
Get the index of the specified element.
ArrayList
  
isEmpty():Boolean
Get if the structure is empty or not.
ArrayList
  
removeElement(element:*):void
Removes an element from the ArrayList.
ArrayList
  
removeElementAt(index:int):*
Removes the element at the specified index from the ArrayList.
ArrayList
  
toArray():Array
Retrieves an Array from the ArrayList.
ArrayList
  
toString():String
Displays the ArrayList in a String.
ArrayList
Property Detail
lengthproperty
length:int  [read-only]

Defines the number of elements contained in the ArrayList.


Implementation
    public function get length():int
Constructor Detail
ArrayList()Constructor
public function ArrayList(initialData:Array = null)

Creates a new ArrayList object.

Parameters
initialData:Array (default = null) — The initial data to add to the ArrayList.
Method Detail
addElement()method
public function addElement(element:*):void

Add an element in the ArrayList.

Parameters

element:* — The element to add.

addElementAt()method 
public function addElementAt(element:*, index:int):void

Add an element in the ArrayList at the specified index.

Parameters

element:* — The element to add.
 
index:int — The index of the element.

clear()method 
public function clear():void

Removes all the elements contained in this ArrayList.

contains()method 
public function contains(element:*, compare:Function = null):Boolean

Returns true if the specified element is contained in the IList or false otherwise.

The comparison function must take two arguments that are issued from the IList and must return a Boolean indicating whetever the two elements are the same or not.

Parameters

element:* — The element to find.
 
compare:Function (default = null) — The comparison function. If null, then the strict equality operator (===) will be used.

Returns
Booleantrue if the element is in the IList.

See also


Example
         var cmp:Function = function(a:Object, b:Object):Boolean
         {
                 // a will always be the element passed to the contains method
                 return a.aProperty == b.aProperty;
         }
         var isContained:Boolean = myList.contains(myObject, cmp);
         
getElementAt()method 
public function getElementAt(index:int):*

Get the element at the specified index.

Parameters

index:int — The index of the element to get.

Returns
* — The element at the specified index.
getElementIndex()method 
public function getElementIndex(element:*):int

Get the index of the specified element. The comparison operator is the strict equality (===).

Parameters

element:* — The element to find.

Returns
int — The index of the element or -1 if the element is not found.
isEmpty()method 
public function isEmpty():Boolean

Get if the structure is empty or not.

Returns
Booleantrue if there is no element in the structure.
removeElement()method 
public function removeElement(element:*):void

Removes an element from the ArrayList.

Parameters

element:* — The element to remove.

removeElementAt()method 
public function removeElementAt(index:int):*

Removes the element at the specified index from the ArrayList.

Parameters

index:int — The index of the element to remove.

Returns
* — The removed element.
toArray()method 
public function toArray():Array

Retrieves an Array from the ArrayList.

Returns
Array — An Array containing the objects.
toString()method 
public function toString():String

Displays the ArrayList in a String.

Returns
String — A String representing the ArrayList.