Packagesystem.data.collections
Classpublic class ArrayCollection
InheritanceArrayCollection Inheritance Object
Implements Collection, Equatable
Subclasses ArrayList, ArrayStack, CoreSet, LinearQueue

This class provides a basic implementation of the Collection interface, to minimize the effort required to implement this interface.

Example :

     import system.data.collections.ArrayCollection ;
     import system.data.Iterator ;
     
     var ar:Array           = ["item1", "item2", "item3", "item4"] ;
     var co:ArrayCollection = new ArrayCollection( ar ) ;
     
     trace ("---- Collection methods") ;
     
     trace ( "insert item5 : " + co.add("item5") ) ;
     trace ( "contains items : " + co.contains("item2") ) ;
     trace ( "get(2) : " + co.get(2) ) ;
     trace ( "isEmpty : " + co.isEmpty() ) ;
     
     trace ( "remove : " + co.remove("item5") ) ;
     
     trace ( "size : " + co.size() ) ;
     
     trace ("toArray : " + co.toArray() ) ;
     trace ( "toString : " + co.toString() ) ;
     trace ( "toSource : " + co.toSource()) ;
     
     trace ("---- iterator") ;
     
     var it:Iterator = co.iterator() ;
     
     while ( it.hasNext() )
     {
         trace ( it.next() ) ;
     }
     
     trace ("---- optional methods") ;
     
     var c1:ArrayCollection = new ArrayCollection(["item1", "item3"]) ;
     var c2:ArrayCollection = new ArrayCollection(["item5", "item6"]) ;
     var c3:ArrayCollection = new ArrayCollection(["item2", "item4"]) ;
     
     trace("co : " + co) ;
     trace("c1 : " + c1) ;
     trace("c2 : " + c2) ;
     
     trace("co containsAll c1 : " + co.containsAll( c1 ) ) ;
     trace("co containsAll c2 : " + co.containsAll( c2 ) ) ;
     trace("co insertAll c2 : " + co.addAll( c2 ) ) ;
     trace("co removeAll c2 : " + co.removeAll( c1 ) ) ;
     trace("co retainAll c3 : " + co.retainAll( c3 ) ) ;
     
     trace("co : " + co) ;
     



Public Methods
 MethodDefined By
  
ArrayCollection(init:* = null)
Creates a new ArrayCollection instance.
ArrayCollection
  
add(o:*):Boolean
Inserts an element in the collection.
ArrayCollection
  
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).
ArrayCollection
  
clear():void
Removes all elements in the collection.
ArrayCollection
  
clone():*
Returns a shallow copy of this collection (optional operation).
ArrayCollection
  
contains(o:*):Boolean
Returns true if this collection contains the specified element.
ArrayCollection
  
Returns true if this collection contains all of the elements of the specified collection.
ArrayCollection
  
equals(o:*):Boolean
Compares the specified object with this object for equality.
ArrayCollection
  
get(key:*):*
Returns the element from this collection at the passed key index.
ArrayCollection
  
indexOf(o:*, fromIndex:uint = 0):int
Returns the index of an element in the collection.
ArrayCollection
  
isEmpty():Boolean
Returns true if this collection contains no elements.
ArrayCollection
  
Returns the iterator reference of the object.
ArrayCollection
  
remove(o:*):*
Removes a single instance of the specified element from this collection, if it is present (optional operation).
ArrayCollection
  
Removes from this Collection all the elements that are contained in the specified Collection (optional operation).
ArrayCollection
  
Retains only the elements in this Collection that are contained in the specified Collection (optional operation).
ArrayCollection
  
size():uint
Returns the number of elements in this collection.
ArrayCollection
  
toArray():Array
Returns an array containing all of the elements in this collection.
ArrayCollection
  
toSource(indent:int = 0):String
Returns the source code string representation of the object.
ArrayCollection
  
toString():String
Returns the string representation of this instance.
ArrayCollection
Constructor Detail
ArrayCollection()Constructor
public function ArrayCollection(init:* = null)

Creates a new ArrayCollection instance.

Parameters
init:* (default = null) — An optional Array or Collection or Iterable object to fill the collection.
Method Detail
add()method
public function add(o:*):Boolean

Inserts an element in the collection.

Parameters

o:*

Returns
Boolean
addAll()method 
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.
clear()method 
public function clear():void

Removes all elements in the collection.

clone()method 
public function clone():*

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

Returns
* — a shallow copy of this collection (optional operation).
contains()method 
public function contains(o:*):Boolean

Returns true if this collection contains the specified element.

Parameters

o:*

Returns
Booleantrue if this collection contains the specified element.
containsAll()method 
public function containsAll(c:Collection):Boolean

Returns true if this collection contains all of the elements of the specified collection.

Parameters

c:Collection

Returns
Booleantrue if this collection contains all of the elements of the specified collection.
equals()method 
public function equals(o:*):Boolean

Compares the specified object with this object for equality.

Parameters

o:*

Returns
Booleantrue if the the specified object is equal with this object.
get()method 
public function get(key:*):*

Returns the element from this collection at the passed key index.

Parameters

key:*

Returns
* — the element from this collection at the passed key index.
indexOf()method 
public function indexOf(o:*, fromIndex:uint = 0):int

Returns the index of an element in the collection.

Parameters

o:*
 
fromIndex:uint (default = 0)

Returns
int — the index of an element in the collection.
isEmpty()method 
public function isEmpty():Boolean

Returns true if this collection contains no elements.

Returns
Booleantrue if this collection contains no elements.
iterator()method 
public function iterator():Iterator

Returns the iterator reference of the object.

Returns
Iterator — the iterator reference of the object.
remove()method 
public function remove(o:*):*

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

Parameters

o:*

Returns
*
removeAll()method 
public function removeAll(c:Collection):Boolean

Removes from this Collection all the elements that are contained in the specified Collection (optional operation).

Parameters

c:Collection

Returns
Boolean
retainAll()method 
public function retainAll(c:Collection):Boolean

Retains only the elements in this Collection that are contained in the specified Collection (optional operation).

Parameters

c:Collection

Returns
Boolean
size()method 
public function size():uint

Returns the number of elements in this collection.

Returns
uint — the number of elements in this collection.
toArray()method 
public function toArray():Array

Returns an array containing all of the elements in this collection.

Note: The returned Array is a reference of the internal Array used in the Collection to store the items. It's not a shallow copy of it.

Returns
Array — an array containing all of the elements in this collection.
toSource()method 
public function toSource(indent:int = 0):String

Returns the source code string representation of the object.

Parameters

indent:int (default = 0)

Returns
String — the source code string representation of the object.
toString()method 
public function toString():String

Returns the string representation of this instance.

Returns
String — the string representation of this instance.