Packagesystem.data.lists
Classpublic class ArrayList
InheritanceArrayList Inheritance ArrayCollection Inheritance Object
Implements List
Subclasses SortedArrayList

Resizable-array implementation of the List interface. Implements all optional list operations, and permits all elements, including null.

Example :

     import system.data.lists.ArrayList ;
     
     var list:ArrayList = new ArrayList() ;
     
     list.add("item1") ;
     list.add("item3") ;
     list.addAt( 1 , "item2" ) ;
      
     trace( list ) ; // {item1,item2,item3}
     trace( list.toSource() ) ; // new system.data.lists.ArrayList(["item1","item2","item3"])
     



Public Properties
 PropertyDefined By
  modCount : int
This property is a protector used in the ListIterator object of this List.
ArrayList
Public Methods
 MethodDefined By
  
ArrayList(init:* = null)
Creates a new ArrayList instance.
ArrayList
  
add(o:*):Boolean
[override] Inserts an element in the collection.
ArrayList
  
addAll(c:Collection):Boolean
[override] Appends all of the elements in the specified collection to the end of this Collection, in the order that they are returned by the specified collection's iterator (optional operation).
ArrayList
  
addAt(index:uint, o:*):void
Inserts the specified element at the specified position in this list (optional operation).
ArrayList
  
clear():void
[override] Removes all elements in the collection.
ArrayList
  
clone():*
[override] Returns a shallow copy of this collection (optional operation).
ArrayList
 Inherited
contains(o:*):Boolean
Returns true if this collection contains the specified element.
ArrayCollection
 Inherited
Returns true if this collection contains all of the elements of the specified collection.
ArrayCollection
  
ensureCapacity(capacity:uint):void
Increases the capacity of this ArrayList instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.
ArrayList
 Inherited
equals(o:*):Boolean
Compares the specified object with this object for equality.
ArrayCollection
 Inherited
get(key:*):*
Returns the element from this collection at the passed key index.
ArrayCollection
 Inherited
indexOf(o:*, fromIndex:uint = 0):int
Returns the index of an element in the collection.
ArrayCollection
 Inherited
isEmpty():Boolean
Returns true if this collection contains no elements.
ArrayCollection
 Inherited
Returns the iterator reference of the object.
ArrayCollection
  
lastIndexOf(o:*, fromIndex:int = 0x7FFFFFFF):int
Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element.
ArrayList
  
listIterator(position:uint = 0):ListIterator
Returns a ListIterator of the elements in this list (in proper sequence).
ArrayList
  
remove(o:*):*
[override] Removes a single instance of the specified element from this collection, if it is present (optional operation).
ArrayList
 Inherited
Removes from this Collection all the elements that are contained in the specified Collection (optional operation).
ArrayCollection
  
removeAt(id:uint, len:int = 1):*
Removes from this list all the elements that are contained between the specific id position and the end of this list (optional operation).
ArrayList
  
removeRange(fromIndex:uint, toIndex:uint):*
Removes from this List all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive.
ArrayList
 Inherited
Retains only the elements in this Collection that are contained in the specified Collection (optional operation).
ArrayCollection
  
set(index:uint, o:*):*
Replaces the element at the specified position in this list with the specified element (optional operation).
ArrayList
 Inherited
size():uint
Returns the number of elements in this collection.
ArrayCollection
  
subList(fromIndex:uint, toIndex:uint):List
Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
ArrayList
 Inherited
toArray():Array
Returns an array containing all of the elements in this collection.
ArrayCollection
 Inherited
toSource(indent:int = 0):String
Returns the source code string representation of the object.
ArrayCollection
 Inherited
toString():String
Returns the string representation of this instance.
ArrayCollection
Property Detail
modCountproperty
modCount:int

This property is a protector used in the ListIterator object of this List.


Implementation
    public function get modCount():int
    public function set modCount(value:int):void
Constructor Detail
ArrayList()Constructor
public function ArrayList(init:* = null)

Creates a new ArrayList instance.

Usage

          new ArrayList() ;
          new ArrayList( ar:Array ) ;
          new ArrayList( it:Iterable ) ;
          new ArrayList( co:Collection ) ;
          new ArrayList( capacity:uint ) ;
         

Parameters
init:* (default = null) — An optional Array or Collection or Iterable object to fill the collection. This parameter can be an uint value to determinates the default capacity of the list.

See also

ensureCapacity
Method Detail
add()method
override public function add(o:*):Boolean

Inserts an element in the collection.

Parameters

o:*

Returns
Boolean
addAll()method 
override public function addAll(c:Collection):Boolean

Appends all of the elements in the specified collection to the end of this Collection, in the order that they are returned by the specified collection's iterator (optional operation).

Parameters

c:Collection

Returns
Booleantrue if this list changed as a result of the call.
addAt()method 
public function addAt(index:uint, o:*):void

Inserts the specified element at the specified position in this list (optional operation).

Parameters

index:uint
 
o:*

clear()method 
override public function clear():void

Removes all elements in the collection.

clone()method 
override public function clone():*

Returns a shallow copy of this collection (optional operation).

Returns
* — a shallow copy of this collection (optional operation).
ensureCapacity()method 
public function ensureCapacity(capacity:uint):void

Increases the capacity of this ArrayList instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.

Parameters

capacity:uint

lastIndexOf()method 
public function lastIndexOf(o:*, fromIndex:int = 0x7FFFFFFF):int

Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element.

Parameters

o:*
 
fromIndex:int (default = 0x7FFFFFFF)

Returns
int — the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element.
listIterator()method 
public function listIterator(position:uint = 0):ListIterator

Returns a ListIterator of the elements in this list (in proper sequence).

Example :

         import system.data.lists.ArrayList ;
         import system.data.ListIterator ;
         
         var a:Array = ["item0", "item1", "item2", "item3", "item4"] ;
         
         var list:ArrayList = new ArrayList( a ) ;
         var it:ListIterator = list.listIterator(2) ;
         
         trace ("---- ListIterator hasPrevious/previous") ;
         
         while(it.hasNext())
         {
             trace(">> " + it.next() + " : " + it.key()) ;
             it.remove() ;
         }
         trace ("next : " + list) ;
         
         trace ("---- ListIterator hasPrevious/previous") ;
         
         var cpt:uint = list.size() ;
         while(it.hasPrevious())
         {
             it.previous() ;
             it.set("element" +  cpt--) ;
         }
         trace ("list : " + list) ;
         

Parameters

position:uint (default = 0)

Returns
ListIterator — a ListIterator of the elements in this list (in proper sequence).
remove()method 
override public function remove(o:*):*

Removes a single instance of the specified element from this collection, if it is present (optional operation).

Parameters

o:*

Returns
*
removeAt()method 
public function removeAt(id:uint, len:int = 1):*

Removes from this list all the elements that are contained between the specific id position and the end of this list (optional operation).

Parameters

id:uint — The index of the element or the first element to remove.
 
len:int (default = 1) — The number of elements to remove (default 1).

Returns
* — The Array representation of all elements removed in the original list.
removeRange()method 
public function removeRange(fromIndex:uint, toIndex:uint):*

Removes from this List all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive.

Shifts any succeeding elements to the left (reduces their index).

This call shortens the list by (toIndex - fromIndex) elements. (If toIndex==fromIndex, this operation has no effect.)

Parameters

fromIndex:uint — The from index (inclusive) to remove elements in the list.
 
toIndex:uint — The to index (exclusive) to remove elements in the list.

Returns
*
set()method 
public function set(index:uint, o:*):*

Replaces the element at the specified position in this list with the specified element (optional operation).

Example :

         import system.data.lists.ArrayList ;
         
         var list:ArrayList = new ArrayList( [ "item1", "item2", "item3", "item4" ] ) ;
         
         list.set(0, "item") ;
         trace(list) ;
         // {item,item2,item3,item4}
         
         list.set(1, undefined) ;
         trace(list) ;
         // {item,item3,item4}
         
         list.set( 5 , "item" ) ;
         trace(list) ;
         // RangeError: The ArrayList.set() method failed, the index '5' argument is out of the size limit.
         

Parameters

index:uint — index of element to replace.
 
o:* — element to be stored at the specified position or if o is undefined the stored value is remove (like with the removeAt() method).

Returns
* — the element previously at the specified position or undefined.
subList()method 
public function subList(fromIndex:uint, toIndex:uint):List

Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.

Parameters

fromIndex:uint
 
toIndex:uint

Returns
List — a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.