Packageorg.as3collections.lists
Classpublic class TypedSortedList
InheritanceTypedSortedList Inheritance TypedList Inheritance TypedCollection Inheritance Object
Implements ISortedList

TypedSortedList works as a wrapper for a ISortedList object. Since ActionScript 3.0 does not support typed arrays, TypedSortedList is a way to create typed lists. It stores the wrapList constructor's argument internaly. So every method call to this class is forwarded to the wrappedList object. The methods that need to be checked for the type of the elements are previously validated before forward the call. If the type of an element requested to be added to this list is incompatible with the type of the list a org.as3coreaddendum.errors.ClassCastError is thrown. The calls that are forwarded to the wrappedList returns the return of the wrappedList call.

TypedSortedList does not allow null elements.

You can also create unique and typed sorted lists. See below the link "ListUtil.getUniqueTypedSortedList()".

View the examples

See also

ListUtil.getTypedSortedList()
ListUtil.getUniqueTypedSortedList()


Public Properties
 PropertyDefined By
 InheritedallEquatable : Boolean
[read-only] Indicates whether all elements in this collection implement the interface org.as3coreaddendum.system.IEquatable.
TypedCollection
  comparator : IComparator
Defines the wrappedList comparator object to be used automatically to sort.
TypedSortedList
 InheritedmodCount : int
[read-only] Returns the return of the call wrappedList.modCount.
TypedList
  options : uint
Defines the wrappedList options to be used automatically to sort.
TypedSortedList
 Inheritedtype : *
Defines the acceptable type of the elements by this collection.
TypedCollection
Public Methods
 MethodDefined By
  
TypedSortedList(wrapList:ISortedList, type:*)
Constructor, creates a new TypedList object.
TypedSortedList
 Inherited
add(element:*):Boolean
The element is validated with the validateType method to be forwarded to wrappedCollection.add.
TypedCollection
 Inherited
addAll(collection:ICollection):Boolean
The collection is validated with the validateCollection method to be forwarded to wrappedCollection.addAll.
TypedCollection
 Inherited
addAllAt(index:int, collection:ICollection):Boolean
The collection is validated to be forwarded to wrappedList.addAllAt.
TypedList
 Inherited
addAt(index:int, element:*):Boolean
The element is validated to be forwarded to wrappedList.addAt.
TypedList
 Inherited
clear():void
Forwards the call to wrappedCollection.clear.
TypedCollection
  
clone():*
[override] Creates and return a new TypedSortedList object with the clone of the wrappedMap object.
TypedSortedList
 Inherited
contains(o:*):Boolean
Forwards the call to wrappedCollection.contains.
TypedCollection
 Inherited
containsAll(collection:ICollection):Boolean
Forwards the call to wrappedCollection.containsAll.
TypedCollection
  
equals(other:*):Boolean
[override] Performs an arbitrary, specific evaluation of equality between this object and the other object.
TypedSortedList
 Inherited
getAt(index:int):*
Forwards the call to wrappedList.getAt.
TypedList
 Inherited
indexOf(element:*, fromIndex:int = 0):int
Forwards the call to wrappedList.indexOf.
TypedList
 Inherited
isEmpty():Boolean
Forwards the call to wrappedCollection.isEmpty.
TypedCollection
 Inherited
Forwards the call to wrappedCollection.iterator.
TypedCollection
 Inherited
lastIndexOf(element:*, fromIndex:int = 0x7fffffff):int
Forwards the call to wrappedList.lastIndexOf.
TypedList
 Inherited
Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list.
TypedList
 Inherited
remove(o:*):Boolean
Forwards the call to wrappedCollection.remove.
TypedCollection
 Inherited
removeAll(collection:ICollection):Boolean
Forwards the call to wrappedCollection.removeAll.
TypedCollection
 Inherited
removeAt(index:int):*
Forwards the call to wrappedList.removeAt.
TypedList
 Inherited
removeRange(fromIndex:int, toIndex:int):ICollection
Forwards the call to wrappedList.removeRange.
TypedList
 Inherited
retainAll(collection:ICollection):Boolean
Forwards the call to wrappedCollection.retainAll.
TypedCollection
 Inherited
reverse():void
Forwards the call to wrappedList.reverse.
TypedList
 Inherited
setAt(index:int, element:*):*
The element is validated to be forwarded to wrappedList.setAt.
TypedList
 Inherited
size():int
Forwards the call to wrappedCollection.size.
TypedCollection
  
sort(compare:Function = null, options:uint = 0):Array
Forwards the call to wrappedList.sort.
TypedSortedList
  
sortOn(fieldName:*, options:* = null):Array
Forwards the call to wrappedList.sortOn.
TypedSortedList
  
subList(fromIndex:int, toIndex:int):IList
[override] Forwards the call to wrappedList.subList.
TypedSortedList
 Inherited
toArray():Array
Forwards the call to wrappedCollection.toArray.
TypedCollection
 Inherited
toString():String
Returns the string representation of this instance.
TypedCollection
Property Detail
comparatorproperty
comparator:IComparator

Defines the wrappedList comparator object to be used automatically to sort.

If this value change the wrappedList is automatically reordered with the new value.


Implementation
    public function get comparator():IComparator
    public function set comparator(value:IComparator):void
optionsproperty 
options:uint

Defines the wrappedList options to be used automatically to sort.

If this value change the list is automatically reordered with the new value.


Implementation
    public function get options():uint
    public function set options(value:uint):void
Constructor Detail
TypedSortedList()Constructor
public function TypedSortedList(wrapList:ISortedList, type:*)

Constructor, creates a new TypedList object.

Parameters
wrapList:ISortedList — the target list to wrap.
 
type:* — the type of the elements allowed by this list.

Throws
ArgumentError — if the wrapList argument is null.
 
ArgumentError — if the type argument is null.
 
org.as3coreaddendum.errors:ClassCastError — if the types of one or more elements in the wrapList argument are incompatible with the type argument.
Method Detail
clone()method
override public function clone():*

Creates and return a new TypedSortedList object with the clone of the wrappedMap object.

Returns
* — a new TypedSortedList object with the clone of the wrappedMap object.
equals()method 
override public function equals(other:*):Boolean

Performs an arbitrary, specific evaluation of equality between this object and the other object.

This implementation considers two differente objects equal if:

This implementation takes care of the order of the elements in the list. So, for two lists are equal the order of elements returned by the iterator must be equal.

Parameters

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

Returns
Booleantrue if the arbitrary evaluation considers the objects equal.
sort()method 
public function sort(compare:Function = null, options:uint = 0):Array

Forwards the call to wrappedList.sort.

Parameters

compare:Function (default = null)
 
options:uint (default = 0)

Returns
Array
sortOn()method 
public function sortOn(fieldName:*, options:* = null):Array

Forwards the call to wrappedList.sortOn.

Parameters

fieldName:*
 
options:* (default = null)

Returns
Array
subList()method 
override public function subList(fromIndex:int, toIndex:int):IList

Forwards the call to wrappedList.subList.

Parameters

fromIndex:int
 
toIndex:int

Returns
IList
Examples
     import org.as3collections.ISortedList;
     import org.as3collections.IListIterator;
     import org.as3collections.lists.SortedArrayList;
     import org.as3collections.lists.TypedSortedList;
     import org.as3collections.utils.ListUtil;
     
     var l1:ISortedList = new SortedArrayList([3, 5, 7], null, Array.NUMERIC);
     
     var list1:ISortedList = new TypedSortedList(l1, int); // you can use this way
     
     //var list1:ISortedList = ListUtil.getTypedSortedList(l1, int); // or you can use this way
     
     list1                          // [3,5,7]
     list1.size()                   // 3
     
     list1.add(8)                   // true
     list1                          // [3,5,7,8]
     list1.size()                   // 4
     
     list1.remove("abc")            // false
     list1                          // [3,4,5,7,8]
     list1.size()                   // 5
     
     var it:IListIterator = list1.listIterator();
     var e:int;
     
     while (it.hasNext())
     {
     
         e = it.next()
         e                          // 3
     
         e = it.next()
         e:                         // 4
     
         e = it.next()
         e                          // 5
     
         if (e == 5)
         {
             it.add("ghi")          // ClassCastError: Invalid element type. element: ghi | type: String | expected type: int
         }
     }
     
     list1.setAt(0, [1,2])          // ClassCastError: Invalid element type. element: 1,2 | type: Array | expected type: int