Package | org.as3collections |
Class | public class AbstractArrayCollection |
Inheritance | AbstractArrayCollection Object |
Implements | ICollection |
Subclasses | AbstractList, AbstractQueue |
ICollection
interface, to minimize the effort required to implement this interface.
This is an abstract class and shouldn't be instantiated directly.
The documentation for each non-abstract method in this class describes its implementation in detail. Each of these methods may be overridden if the collection being implemented admits a more efficient implementation.
This class maintains a native Array
object as its source.
IMPORTANT:
This class implements equality through org.as3coreaddendum.system.IEquatable
interface in the equals
method and in all methods that compares the elements inside this collection (i.e. contains
, containsAll
, remove
, removeAll
and retainAll
).
In order to this collection uses the equals
method of its elements in comparisons (rather than default '==' operator), all elements in this collection must implement the
org.as3coreaddendum.system.IEquatable
interface and also the supplied element.
For example:
myCollection.contains(myElement);
All elements inside myCollection
, and myElement
, must implement the org.as3coreaddendum.system.IEquatable
interface so that equals
method of each element can be used in the comparison.
Otherwise '==' operator is used.
All subclasses of this class must conform with this behavior.
This documentation is partially based in the Java Collections Framework JavaDoc documentation. For further information see Java Collections Framework
See also
Property | Defined By | ||
---|---|---|---|
allEquatable : Boolean [read-only]
Indicates whether all elements in this collection implement the interface org.as3coreaddendum.system.IEquatable. | AbstractArrayCollection |
Method | Defined By | ||
---|---|---|---|
AbstractArrayCollection(source:Array = null)
This is an abstract class and shouldn't be instantiated directly. | AbstractArrayCollection | ||
add(element:*):Boolean
Ensures that this collection contains the specified element (optional operation). | AbstractArrayCollection | ||
addAll(collection:ICollection):Boolean
Adds all of the elements in the specified collection to this collection (optional operation). | AbstractArrayCollection | ||
clear():void
Removes all of the elements from this collection (optional operation). | AbstractArrayCollection | ||
clone():*
Creates and return a shallow copy of this collection. | AbstractArrayCollection | ||
contains(o:*):Boolean
Returns true if this collection contains the specified object. | AbstractArrayCollection | ||
containsAll(collection:ICollection):Boolean
Returns true if this collection contains all of the elements in the specified collection. | AbstractArrayCollection | ||
equals(other:*):Boolean
This method uses CollectionUtil.equalNotConsideringOrder method to perform equality, sending this collection and other argument. | AbstractArrayCollection | ||
isEmpty():Boolean
Returns true if this collection contains no elements. | AbstractArrayCollection | ||
Returns an iterator over a set of elements. | AbstractArrayCollection | ||
remove(o:*):Boolean
Removes a single instance (only one occurrence) of the specified object from this collection, if it is present (optional operation). | AbstractArrayCollection | ||
removeAll(collection:ICollection):Boolean
Removes all of this collection's elements that are also contained in the specified collection (optional operation). | AbstractArrayCollection | ||
retainAll(collection:ICollection):Boolean
Retains only the elements in this collection that are contained in the specified collection (optional operation). | AbstractArrayCollection | ||
size():int
Returns the number of elements in this collection. | AbstractArrayCollection | ||
toArray():Array
Returns an array containing all of the elements in this collection. | AbstractArrayCollection | ||
toString():String
Returns the string representation of this instance. | AbstractArrayCollection |
allEquatable | property |
allEquatable:Boolean
[read-only]
Indicates whether all elements in this collection implement the interface org.as3coreaddendum.system.IEquatable
.
public function get allEquatable():Boolean
AbstractArrayCollection | () | Constructor |
public function AbstractArrayCollection(source:Array = null)
This is an abstract class and shouldn't be instantiated directly.
Parameterssource:Array (default = null ) — an array to fill the collection.
|
IllegalOperationError — If this class is instantiated directly. In other words, if there is not another class extending this class.
|
add | () | method |
public function add(element:*):Boolean
Ensures that this collection contains the specified element (optional operation).
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 error (rather than returning false
).
This preserves the invariant that a collection always contains the specified element after this call returns.
This implementation always throws an UnsupportedOperationError
.
Parameters
element:* — the element to be added.
|
Boolean — 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.
|
org.as3coreaddendum.errors:UnsupportedOperationError — if the add operation is not supported by this collection.
| |
org.as3coreaddendum.errors:ClassCastError — if the class of the specified element prevents it from being added to this collection.
| |
ArgumentError — if the specified element is null and this collection does not permit null elements.
|
addAll | () | method |
public function addAll(collection:ICollection):Boolean
Adds all of the elements in the specified collection to this collection (optional operation).
This implementation iterates over the specified collection, and adds each object returned by the iterator to this collection, in turn.
Note that this implementation will throw an UnsupportedOperationError
unless add
is overridden (assuming the specified collection is non-empty).
Parameters
collection:ICollection — the collection containing elements to be added to this collection.
|
Boolean — true if this collection changed as a result of the call.
|
org.as3coreaddendum.errors:UnsupportedOperationError — if the addAll operation is not supported by this collection.
| |
org.as3coreaddendum.errors:ClassCastError — if the class of an element of the specified collection prevents it from being added to this collection.
| |
ArgumentError — if the specified collection contains a null element and this collection does not permit null elements, or if the specified collection is null .
|
clear | () | method |
public function clear():void
Removes all of the elements from this collection (optional operation). The collection will be empty after this method returns.
This implementation always throws an UnsupportedOperationError
.
org.as3coreaddendum.errors:UnsupportedOperationError — if the clear operation is not supported by this collection.
|
clone | () | method |
public function clone():*
Creates and return a shallow copy of this collection.
This implementation always throws a org.as3coreaddendum.errors.CloneNotSupportedError
.
* — A new object that is a shallow copy of this instance.
|
org.as3coreaddendum.errors:CloneNotSupportedError — if this collection doesn't support clone.
|
contains | () | method |
public function contains(o:*):Boolean
Returns true
if this collection contains the specified object.
If all elements in this collection and o
argument implement org.as3coreaddendum.system.IEquatable
, this implementation will iterate over this collection using equals
method of the elements.
Otherwise this implementation uses native Array.indexOf
method.
Parameters
o:* — object whose presence in this collection is to be tested.
|
Boolean — true if this collection contains the specified object.
|
org.as3coreaddendum.errors:ClassCastError — if the type of the specified object is incompatible with this collection (optional).
| |
ArgumentError — if the specified object is null and this collection does not permit null elements (optional).
|
containsAll | () | method |
public function containsAll(collection:ICollection):Boolean
Returns true
if this collection contains all of the elements in the specified collection.
This implementation iterates over the specified collection, checking each element returned by the iterator in turn to see if it's contained in this collection.
If all elements are so contained true
is returned, otherwise false
.
If all elements in this collection and all elements in collection
argument implement org.as3coreaddendum.system.IEquatable
, equals
method of the elements will be used.
Otherwise this implementation uses native Array.indexOf
method.
Parameters
collection:ICollection — the collection to be checked for containment in this collection.
|
Boolean — true if this collection contains all of the elements in the specified collection.
|
org.as3coreaddendum.errors:ClassCastError — if the types of one or more elements in the specified collection are incompatible with this collection (optional).
| |
ArgumentError — if the specified collection contains one or more null elements and this collection does not permit null elements (optional), or if the specified collection is null .
|
equals | () | method |
public function equals(other:*):Boolean
This method uses CollectionUtil.equalNotConsideringOrder
method to perform equality, sending this collection and other
argument.
Parameters
other:* — the object to be compared for equality.
|
Boolean — true if the arbitrary evaluation considers the objects equal.
|
See also
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():IIterator
Returns an iterator over a set of elements.
This implementation always throws an UnsupportedOperationError
.
IIterator — an iterator over a set of elements.
|
org.as3coreaddendum.errors:UnsupportedOperationError — this method must be overridden in subclass.
|
See also
remove | () | method |
public function remove(o:*):Boolean
Removes a single instance (only one occurrence) of the specified object from this collection, if it is present (optional operation).
If all elements in this collection and o
argument implement org.as3coreaddendum.system.IEquatable
, this implementation iterates over this collection looking for the specified element.
If it finds the element, it removes the element from the collection using the iterator's remove method.
In this case, note that this implementation throws an UnsupportedOperationError
if the iterator returned by this collection's iterator method does not implement the remove
method.
Otherwise this implementation uses native Array.indexOf
method to get the index of the element and then uses native Array.splice
method to remove it.
Parameters
o:* — the object to be removed from this collection, if present.
|
Boolean — true if an object was removed as a result of this call.
|
org.as3coreaddendum.errors:UnsupportedOperationError — if the remove operation is not supported by this collection.
| |
org.as3coreaddendum.errors:ClassCastError — if the type of the specified object is incompatible with this collection (optional).
| |
ArgumentError — if the specified object is null and this collection does not permit null elements (optional).
|
removeAll | () | method |
public function removeAll(collection:ICollection):Boolean
Removes all of 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.
This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection (using contains
method of the collection
argument).
If it's so contained, it's removed from this collection with the iterator's remove
method.
Note that this implementation will throw an UnsupportedOperationError
if the iterator returned by the iterator method does not implement the remove
method and this collection contains one or more elements in common with the specified collection.
Parameters
collection:ICollection — the collection containing elements to be removed from this collection.
|
Boolean — true if this collection changed as a result of the call.
|
org.as3coreaddendum.errors:UnsupportedOperationError — if the removeAll operation is not supported by this collection.
| |
org.as3coreaddendum.errors:ClassCastError — if the types of one or more elements in the specified collection are incompatible with this collection (optional).
| |
ArgumentError — if the specified collection contains a null element and this collection does not permit null elements, or if the specified collection is null .
|
retainAll | () | method |
public function retainAll(collection:ICollection):Boolean
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.
This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection (using contains
method of the collection
argument).
If it's not so contained, it's removed from this collection with the iterator's remove
method.
Note that this implementation will throw an UnsupportedOperationError
if the iterator returned by the iterator method does not implement the remove
method and this collection contains one or more elements not present in the specified collection.
Parameters
collection:ICollection — the collection containing elements to be retained in this collection.
|
Boolean — true if this collection changed as a result of the call.
|
org.as3coreaddendum.errors:UnsupportedOperationError — if the retainAll operation is not supported by this collection.
| |
org.as3coreaddendum.errors:ClassCastError — if the types of one or more elements in this collection are incompatible with the specified collection (optional).
| |
ArgumentError — if the specified collection contains a null element and this collection does not permit null elements (optional), or if the specified collection is null .
|
size | () | method |
public function size():int
Returns the number of elements in this collection.
Returnsint — the number of elements in this collection.
|
toArray | () | method |
public function toArray():Array
Returns an array containing all of the elements in this collection.
If this 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.
ReturnsArray — a new array object containing all of the elements in this collection.
|
toString | () | method |
public function toString():String
Returns the string representation of this instance.
This method uses CollectionUtil.toString
method.
String — the string representation of this instance.
|
See also