| Package | system.data.collections |
| Class | public class ArrayCollection |
| Inheritance | ArrayCollection Object |
| Implements | Collection, Equatable |
| Subclasses | ArrayList, ArrayStack, CoreSet, LinearQueue |
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) ;
| Method | Defined 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 | ||
containsAll(c:Collection):Boolean
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 | ||
removeAll(c:Collection):Boolean
Removes from this Collection all the elements that are contained in the specified Collection (optional operation). | ArrayCollection | ||
retainAll(c:Collection):Boolean
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 | ||
| ArrayCollection | () | Constructor |
public function ArrayCollection(init:* = null)Creates a new ArrayCollection instance.
Parametersinit:* (default = null) — An optional Array or Collection or Iterable object to fill the collection.
|
| add | () | method |
public function add(o:*):BooleanInserts an element in the collection.
Parameters
o:* |
Boolean |
| addAll | () | method |
public function addAll(c:Collection):BooleanAppends 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 |
Boolean — true if this list changed as a result of the call.
|
| clear | () | method |
public function clear():voidRemoves 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:* |
Boolean — true 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 |
Boolean — true if this collection contains all of the elements of the specified collection.
|
| equals | () | method |
public function equals(o:*):BooleanCompares the specified object with this object for equality.
Parameters
o:* |
Boolean — true 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:* |
* — the element from this collection at the passed key index.
|
| indexOf | () | method |
public function indexOf(o:*, fromIndex:uint = 0):intReturns the index of an element in the collection.
Parameters
o:* | |
fromIndex:uint (default = 0) |
int — the index of an element in the collection.
|
| isEmpty | () | method |
public function isEmpty():Boolean
Returns true if this collection contains no elements.
Boolean — true if this collection contains no elements.
|
| iterator | () | method |
public function iterator():IteratorReturns the iterator reference of the object.
ReturnsIterator — 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:* |
* |
| removeAll | () | method |
public function removeAll(c:Collection):BooleanRemoves from this Collection all the elements that are contained in the specified Collection (optional operation).
Parameters
c:Collection |
Boolean |
| retainAll | () | method |
public function retainAll(c:Collection):BooleanRetains only the elements in this Collection that are contained in the specified Collection (optional operation).
Parameters
c:Collection |
Boolean |
| size | () | method |
public function size():uintReturns the number of elements in this collection.
Returnsuint — the number of elements in this collection.
|
| toArray | () | method |
public function toArray():ArrayReturns 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.
ReturnsArray — an array containing all of the elements in this collection.
|
| toSource | () | method |
public function toSource(indent:int = 0):StringReturns the source code string representation of the object.
Parameters
indent:int (default = 0) |
String — the source code string representation of the object.
|
| toString | () | method |
public function toString():StringReturns the string representation of this instance.
ReturnsString — the string representation of this instance.
|