Packageorg.as3collections
Classpublic class AbstractList
InheritanceAbstractList Inheritance AbstractArrayCollection Inheritance Object
Implements IList
Subclasses ArrayList, ReadOnlyArrayList

This class provides a skeletal implementation of the IList 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 documentation is partially based in the Java Collections Framework JavaDoc documentation. For further information see Java Collections Framework

See also

IList
ArrayList


Public Properties
 PropertyDefined By
 InheritedallEquatable : Boolean
[read-only] Indicates whether all elements in this collection implement the interface org.as3coreaddendum.system.IEquatable.
AbstractArrayCollection
  modCount : int
[read-only] The number of times this list has been structurally modified.
AbstractList
Public Methods
 MethodDefined By
  
AbstractList(source:Array = null)
This is an abstract class and shouldn't be instantiated directly.
AbstractList
  
add(element:*):Boolean
[override] Appends the specified element to the end of this list (optional operation).
AbstractList
  
addAll(collection:ICollection):Boolean
[override] Adds all of the elements in the specified collection to this list (optional operation).
AbstractList
  
addAllAt(index:int, collection:ICollection):Boolean
Inserts all of the elements in the specified collection into this list at the specified position (optional operation).
AbstractList
  
addAt(index:int, element:*):Boolean
Inserts the specified element at the specified position in this list (optional operation).
AbstractList
 Inherited
clear():void
Removes all of the elements from this collection (optional operation).
AbstractArrayCollection
 Inherited
clone():*
Creates and return a shallow copy of this collection.
AbstractArrayCollection
 Inherited
contains(o:*):Boolean
Returns true if this collection contains the specified object.
AbstractArrayCollection
 Inherited
containsAll(collection:ICollection):Boolean
Returns true if this collection contains all of the elements in the specified collection.
AbstractArrayCollection
  
equals(other:*):Boolean
[override] This method uses CollectionUtil.equalConsideringOrder method to perform equality, sending this list and other argument.
AbstractList
  
getAt(index:int):*
Returns the element at the specified position in this list.
AbstractList
  
indexOf(element:*, fromIndex:int = 0):int
Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
AbstractList
 Inherited
isEmpty():Boolean
Returns true if this collection contains no elements.
AbstractArrayCollection
 Inherited
Returns an iterator over a set of elements.
AbstractArrayCollection
  
lastIndexOf(element:*, fromIndex:int = 0x7fffffff):int
Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.
AbstractList
  
Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list.
AbstractList
 Inherited
remove(o:*):Boolean
Removes a single instance (only one occurrence) of the specified object from this collection, if it is present (optional operation).
AbstractArrayCollection
 Inherited
removeAll(collection:ICollection):Boolean
Removes all of this collection's elements that are also contained in the specified collection (optional operation).
AbstractArrayCollection
  
removeAt(index:int):*
Removes the element at the specified position in this list (optional operation).
AbstractList
  
removeRange(fromIndex:int, toIndex:int):ICollection
Removes all of the elements whose index is between fromIndex, inclusive, and toIndex, exclusive (optional operation).
AbstractList
 Inherited
retainAll(collection:ICollection):Boolean
Retains only the elements in this collection that are contained in the specified collection (optional operation).
AbstractArrayCollection
  
reverse():void
Reverses the order of the elements in this list.
AbstractList
  
setAt(index:int, element:*):*
Replaces the element at the specified position in this list with the specified element (optional operation).
AbstractList
 Inherited
size():int
Returns the number of elements in this collection.
AbstractArrayCollection
  
subList(fromIndex:int, toIndex:int):IList
Returns a new list that is a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
AbstractList
 Inherited
toArray():Array
Returns an array containing all of the elements in this collection.
AbstractArrayCollection
 Inherited
toString():String
Returns the string representation of this instance.
AbstractArrayCollection
Property Detail
modCountproperty
modCount:int  [read-only]

The number of times this list has been structurally modified. Structural modifications are those that change the size of the list.

This field is used by the list iterator implementation returned by the listIterator method. If the value of this field changes unexpectedly, the list iterator will throw a org.as3collections.errors.ConcurrentModificationError in response to the next, remove, previous, set or add operations.

Implementations merely has to increment this field in its add, remove and any other methods that result in structural modifications to the list. A single call to add or remove must add no more than one to this field.


Implementation
    public function get modCount():int
Constructor Detail
AbstractList()Constructor
public function AbstractList(source:Array = null)

This is an abstract class and shouldn't be instantiated directly.

Parameters
source:Array (default = null) — an array to fill the list.

Throws
IllegalOperationError — If this class is instantiated directly, in other words, if there is not another class extending this class.
Method Detail
add()method
override public function add(element:*):Boolean

Appends the specified element to the end of this list (optional operation).

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

If a list 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 list always contains the specified element after this call returns.

This implementation calls addAt(size(), element).

Note that this implementation throws an UnsupportedOperationError unless addAt is overridden.

Parameters

element:* — the element to be added.

Returns
Booleantrue if this list changed as a result of the call. Returns false if this list does not permit duplicates and already contains the specified element.

Throws
org.as3coreaddendum.errors:UnsupportedOperationError — if the add operation is not supported by this list.
 
org.as3coreaddendum.errors:ClassCastError — if the class of the specified element prevents it from being added to this list.
 
ArgumentError — if the specified element is null and this list does not permit null elements.
addAll()method 
override public function addAll(collection:ICollection):Boolean

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

This implementation calls addAllAt(size(), collection).

Note that this implementation will throw an UnsupportedOperationError unless addAt is overridden (assuming the specified collection is non-empty).

Parameters

collection:ICollection — the collection containing elements to be added to this list.

Returns
Booleantrue if this list changed as a result of the call.

Throws
org.as3coreaddendum.errors:UnsupportedOperationError — if the addAll operation is not supported by this list.
 
org.as3coreaddendum.errors:ClassCastError — if the class of an element of the specified collection prevents it from being added to this list.
 
ArgumentError — if the specified collection contains a null element and this list does not permit null elements, or if the specified collection is null.
addAllAt()method 
public function addAllAt(index:int, collection:ICollection):Boolean

Inserts all of the elements in the specified collection into this list at the specified position (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in this list in the order that they are returned by the specified collection's iterator.

This implementation gets an iterator over the specified collection and iterates over it, inserting the elements obtained from the iterator into this list at the appropriate position, one at a time, using addAt. Other implementations can override this method for efficiency.

Note that this implementation throws an UnsupportedOperationError unless addAt is overridden.

Parameters

index:int — index at which to insert the first element from the specified collection.
 
collection:ICollection — the collection containing elements to be added to this list.

Returns
Booleantrue if this list changed as a result of the call.

Throws
org.as3coreaddendum.errors:UnsupportedOperationError — if the addAllAt operation is not supported by this list.
 
org.as3coreaddendum.errors:ClassCastError — if the class of an element of the specified collection prevents it from being added to this list.
 
ArgumentError — if the specified collection contains a null element and this list does not permit null elements, or if the specified collection is null.
 
IndexOutOfBoundsError — if the index is out of range (index < 0 || index > size()).
addAt()method 
public function addAt(index:int, element:*):Boolean

Inserts the specified element at the specified position in this list (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

This implementation always throws an UnsupportedOperationError.

Parameters

index:int — index at which the specified element is to be inserted.
 
element:* — the element to be added.

Returns
Booleantrue if this list changed as a result of the call. Returns false if this list does not permit duplicates and already contains the specified element.

Throws
org.as3coreaddendum.errors:UnsupportedOperationError — if the addAt operation is not supported by this list.
 
org.as3coreaddendum.errors:ClassCastError — if the class of the specified element prevents it from being added to this list.
 
ArgumentError — if the specified element is null and this list does not permit null elements.
 
IndexOutOfBoundsError — if the index is out of range (index < 0 || index > size()).
equals()method 
override public function equals(other:*):Boolean

This method uses CollectionUtil.equalConsideringOrder method to perform equality, sending this list and other argument.

Parameters

other:* — the object to be compared for equality.

Returns
Booleantrue if the arbitrary evaluation considers the objects equal.

See also

getAt()method 
public function getAt(index:int):*

Returns the element at the specified position in this list.

Parameters

index:int — index of the element to return.

Returns
* — the element at the specified position in this list.

Throws
IndexOutOfBoundsError — if the index is out of range (index < 0 || index >= size()).
indexOf()method 
public function indexOf(element:*, fromIndex:int = 0):int

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

If all elements in this list and element argument implement org.as3coreaddendum.system.IEquatable, this implementation will iterate over this list using equals method of the elements. Otherwise this implementation uses native Array.indexOf method.

Parameters

element:* — the element to search for.
 
fromIndex:int (default = 0) — the position in the list from which to start searching for the element.

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

Throws
org.as3coreaddendum.errors:ClassCastError — if the class of the specified element is incompatible with this list (optional).
 
ArgumentError — if the specified element is null and this list does not permit null elements (optional).
lastIndexOf()method 
public function lastIndexOf(element:*, fromIndex:int = 0x7fffffff):int

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

If all elements in this list and element argument implement org.as3coreaddendum.system.IEquatable, this implementation will iterate over this list using equals method of the elements. Otherwise this implementation uses native Array.lastIndexOf method.

Parameters

element:* — the element to search for.
 
fromIndex:int (default = 0x7fffffff) — the position in the list from which to start searching for the element. The default is the maximum value allowed for an index. If you do not specify fromIndex, the search starts at the last item in the list.

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

Throws
org.as3coreaddendum.errors:ClassCastError — if the class of the specified element is incompatible with this list (optional).
 
ArgumentError — if the specified element is null and this list does not permit null elements (optional).
listIterator()method 
public function listIterator(index:int = 0):IListIterator

Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list. The specified index indicates the first element that would be returned by an initial call to next. An initial call to previous would return the element with the specified index minus one.

This implementation always throws an UnsupportedOperationError.

Parameters

index:int (default = 0) — index of first element to be returned from the list iterator (by a call to the next method)

Returns
IListIterator — a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list.

See also

removeAt()method 
public function removeAt(index:int):*

Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.

This implementation always throws an UnsupportedOperationError.

Parameters

index:int — the index of the element to be removed.

Returns
* — the element previously at the specified position.

Throws
org.as3coreaddendum.errors:UnsupportedOperationError — if the removeAt operation is not supported by this list.
 
IndexOutOfBoundsError — if the index is out of range (index < 0 || index >= size()).
removeRange()method 
public function removeRange(fromIndex:int, toIndex:int):ICollection

Removes all of the elements whose index is between fromIndex, inclusive, and toIndex, exclusive (optional operation). Shifts any subsequent elements to the left (subtracts their indices).

If toIndex == fromIndex, this operation has no effect.

This implementation always throws an UnsupportedOperationError.

Parameters

fromIndex:int — the index to start removing elements (inclusive).
 
toIndex:int — the index to stop removing elements (exclusive).

Returns
ICollection — a new collection containing all the removed elements.

Throws
org.as3coreaddendum.errors:UnsupportedOperationError — if the removeRange operation is not supported by this list.
 
IndexOutOfBoundsError — if fromIndex or toIndex is out of range (index < 0 || index > size()).
reverse()method 
public function reverse():void

Reverses the order of the elements in this list. This implementation uses native Array.reverse method.

setAt()method 
public function setAt(index:int, element:*):*

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

This implementation always throws an UnsupportedOperationError.

Parameters

index:int — index of the element to replace.
 
element:* — element to be stored at the specified position.

Returns
* — the element previously at the specified position.

Throws
org.as3coreaddendum.errors:UnsupportedOperationError — if the setAt operation is not supported by this list.
 
org.as3coreaddendum.errors:ClassCastError — if the class of the specified element prevents it from being added to this list.
 
ArgumentError — if the specified element is null and this list does not permit null elements.
 
IndexOutOfBoundsError — if the index is out of range (index < 0 || index >= size()).
subList()method 
public function subList(fromIndex:int, toIndex:int):IList

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

This list should not be modified.

The returned list should support all of the optional list operations supported by this list.

This implementation always throws an UnsupportedOperationError.

Parameters

fromIndex:int — the index to start retrieving elements (inclusive).
 
toIndex:int — the index to stop retrieving elements (exclusive).

Returns
IList — a new list that is a view of the specified range within this list.

Throws
org.as3coreaddendum.errors:UnsupportedOperationError — if the subList operation is not supported by this list.
 
IndexOutOfBoundsError — if fromIndex or toIndex is out of range (index < 0 || index > size()).