Packagecom.bourre.collection
Interfacepublic interface Collection extends Iterable
SubinterfacesList
ImplementorsGrid, Queue, WeakCollection

Player version: Flash Player 9.0
Language version: ActionScript 3.0

The root interface in the collection hierarchy. A collection represents a group of objects, known as its elements. Some collections allow duplicate elements and others do not. Some are ordered and others unordered. This interface is typically used to pass collections around and manipulate them where maximum generality is desired.

The "destructive" methods contained in this interface, that is, the methods that modify the collection on which they operate, are specified to throw UnsupportedOperationException if this collection does not support the operation. If this is the case, these methods may, but are not required to, throw an UnsupportedOperationException if the invocation would have no effect on the collection. For example, invoking the addAll(Collection) method on an unmodifiable collection may, but is not required to, throw the exception if the collection to be added is empty.

Some collection implementations have restrictions on the elements that they may contain. For example, some implementations prohibit null elements, and some have restrictions on the types of their elements. Attempting to add an ineligible element throws an unchecked exception, typically NullPointerException or ClassCastException. Attempting to query the presence of an ineligible element may throw an exception, or it may simply return false; some implementations will exhibit the former behavior and some will exhibit the latter. More generally, attempting an operation on an ineligible element whose completion would not result in the insertion of an ineligible element into the collection may throw an exception or it may succeed, at the option of the implementation. Such exceptions are marked as "optional" in the specification for this interface.

When dealing with typed and untyped collection, the following rules apply :



Public Methods
 MethodDefined by
  
add(o:Object):Boolean
Ensures that this collection contains the specified element (optional operation).
Collection
  
addAll(c:Collection):Boolean
Adds all of the elements in the specified collection to this collection (optional operation).
Collection
  
clear():void
Removes all of the elements from this collection (optional operation).
Collection
  
contains(o:Object):Boolean
Returns true if this collection contains the specified element.
Collection
  
Returns true if this collection contains all of the elements in the specified collection.
Collection
  
isEmpty():Boolean
Returns true if this collection contains no elements.
Collection
 Inherited
Returns an iterator over the elements in this collection.
Iterable
  
remove(o:Object):Boolean
Removes a single instance of the specified element from this collection, if this collection contains one or more such elements.
Collection
  
removeAll(c:Collection):Boolean
Removes all this collection's elements that are also contained in the specified collection (optional operation).
Collection
  
retainAll(c:Collection):Boolean
Retains only the elements in this collection that are contained in the specified collection (optional operation).
Collection
  
size():uint
Returns the number of elements in this collection.
Collection
  
toArray():Array
Returns an array containing all of the elements in this collection.
Collection
Method detail
add()method
public function add(o:Object):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Ensures that this collection contains the specified element (optional operation). Returns true if this collection changed as a result of the call. (Returns false if this collection does not permit duplicates and already contains the specified element.)

Collections that support this operation may place limitations on what elements may be added to this collection. In particular, some collections will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. Collection classes should clearly specify in their documentation any restrictions on what elements may be added.

If a collection refuses to add a particular element for any reason other than that it already contains the element, it must throw an exception (rather than returning false). This preserves the invariant that a collection always contains the specified element after this call returns.

Parameters
o:Object — o element whose presence in this collection is to be ensured.

Returns
Booleantrue if this collection changed as a result of the call

Throws
UnsupportedOperationExceptionadd is not supported by this collection.
 
ClassCastException — class of the specified element prevents it from being added to this collection.
 
NullPointerException — if the specified element is null and this collection does not support null elements.
 
IllegalArgumentException — some aspect of this element prevents it from being added to this collection.
addAll()method 
public function addAll(c:Collection):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Adds all of the elements in the specified collection to this collection (optional operation).

Parameters
c:Collection — c elements to be inserted into this collection.

Returns
Booleantrue if this collection changed as a result of the call

Throws
UnsupportedOperationException — if this collection does not support the addAll method.
 
ClassCastException — if the class of an element of the specified collection prevents it from being added to this collection.
 
NullPointerException — if the specified collection contains one or more null elements and this collection does not support null elements, or if the specified collection is null.
 
IllegalArgumentException — some aspect of an element of the specified collection prevents it from being added to this collection.

See also

clear()method 
public function clear():void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Removes all of the elements from this collection (optional operation). This collection will be empty after this method returns unless it throws an exception.


Throws
UnsupportedOperationException — if the clear method is not supported by this collection.
contains()method 
public function contains(o:Object):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns true if this collection contains the specified element.

Parameters
o:Object — o element whose presence in this collection is to be tested.

Returns
Booleantrue if this collection contains the specified element

Throws
ClassCastException — if the type of the specified element is incompatible with this collection (optional).
 
NullPointerException — if the specified element is null and this collection does not support null elements (optional).
containsAll()method 
public function containsAll(c:Collection):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

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

Parameters
c:Collection — c collection to be checked for containment in this collection.

Returns
Booleantrue if this collection contains all of the elements in the specified collection

Throws
ClassCastException — if the types of one or more elements in the specified collection are incompatible with this collection (optional).
 
NullPointerException — if the specified collection contains one or more null elements and this collection does not support null elements (optional).
 
NullPointerException — if the specified collection is null.

See also

isEmpty()method 
public function isEmpty():Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns true if this collection contains no elements.

Returns
Booleantrue if this collection contains no elements
remove()method 
public function remove(o:Object):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Removes a single instance of the specified element from this collection, if this collection contains one or more such elements. Returns true if this collection contained the specified element (or equivalently, if this collection changed as a result of the call).

Parameters
o:Object — o element to be removed from this collection, if present.

Returns
Booleantrue if this collection changed as a result of the call

Throws
ClassCastException — if the type of the specified element is incompatible with this collection (optional).
 
NullPointerException — if the specified element is null and this collection does not support null elements (optional).
 
UnsupportedOperationExceptionremove is not supported by this collection.
removeAll()method 
public function removeAll(c:Collection):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Removes all this collection's elements that are also contained in the specified collection (optional operation). After this call returns, this collection will contain no elements in common with the specified collection.

Parameters
c:Collection — c elements to be removed from this collection.

Returns
Booleantrue if this collection changed as a result of the call

Throws
UnsupportedOperationException — if the removeAll method is not supported by this collection.
 
ClassCastException — if the types of one or more elements in this collection are incompatible with the specified collection (optional).
 
NullPointerException — if this collection contains one or more null elements and the specified collection does not support null elements (optional).
 
NullPointerException — if the specified collection is null.

See also

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

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Retains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection.

Parameters
c:Collection — c elements to be retained in this collection.

Returns
Booleantrue if this collection changed as a result of the call

Throws
UnsupportedOperationException — if the retainAll method is not supported by this Collection.
 
ClassCastException — if the types of one or more elements in this collection are incompatible with the specified collection (optional).
 
NullPointerException — if this collection contains one or more null elements and the specified collection does not support null elements (optional).
 
NullPointerException — if the specified collection is null.

See also

size()method 
public function size():uint

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns the number of elements in this collection.

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

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns an array containing all of the elements in this collection. If the collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.

The returned array will be "safe" in that no references to it are maintained by this collection. (In other words, this method must allocate a new array even if this collection is backed by an array). The caller is thus free to modify the returned array.

This method acts as bridge between array-based and collection-based APIs.

Returns
Array — an array containing all of the elements in this collection