Package | org.as3collections.lists |
Class | public class TypedSortedList |
Inheritance | TypedSortedList TypedList TypedCollection 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()".
See also
Property | Defined By | ||
---|---|---|---|
allEquatable : 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 | ||
modCount : 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 | ||
type : *
Defines the acceptable type of the elements by this collection. | TypedCollection |
Method | Defined By | ||
---|---|---|---|
TypedSortedList(wrapList:ISortedList, type:*)
Constructor, creates a new TypedList object. | TypedSortedList | ||
add(element:*):Boolean
The element is validated with the validateType method to be forwarded to wrappedCollection.add. | TypedCollection | ||
addAll(collection:ICollection):Boolean
The collection is validated with the validateCollection method to be forwarded to wrappedCollection.addAll. | TypedCollection | ||
addAllAt(index:int, collection:ICollection):Boolean
The collection is validated to be forwarded to wrappedList.addAllAt. | TypedList | ||
addAt(index:int, element:*):Boolean
The element is validated to be forwarded to wrappedList.addAt. | TypedList | ||
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 | ||
contains(o:*):Boolean
Forwards the call to wrappedCollection.contains. | TypedCollection | ||
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 | ||
getAt(index:int):*
Forwards the call to wrappedList.getAt. | TypedList | ||
indexOf(element:*, fromIndex:int = 0):int
Forwards the call to wrappedList.indexOf. | TypedList | ||
isEmpty():Boolean
Forwards the call to wrappedCollection.isEmpty. | TypedCollection | ||
Forwards the call to wrappedCollection.iterator. | TypedCollection | ||
lastIndexOf(element:*, fromIndex:int = 0x7fffffff):int
Forwards the call to wrappedList.lastIndexOf. | TypedList | ||
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. | TypedList | ||
remove(o:*):Boolean
Forwards the call to wrappedCollection.remove. | TypedCollection | ||
removeAll(collection:ICollection):Boolean
Forwards the call to wrappedCollection.removeAll. | TypedCollection | ||
removeAt(index:int):*
Forwards the call to wrappedList.removeAt. | TypedList | ||
removeRange(fromIndex:int, toIndex:int):ICollection
Forwards the call to wrappedList.removeRange. | TypedList | ||
retainAll(collection:ICollection):Boolean
Forwards the call to wrappedCollection.retainAll. | TypedCollection | ||
reverse():void
Forwards the call to wrappedList.reverse. | TypedList | ||
setAt(index:int, element:*):*
The element is validated to be forwarded to wrappedList.setAt. | TypedList | ||
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 | ||
[override]
Forwards the call to wrappedList.subList. | TypedSortedList | ||
toArray():Array
Forwards the call to wrappedCollection.toArray. | TypedCollection | ||
toString():String
Returns the string representation of this instance. | TypedCollection |
comparator | property |
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.
public function get comparator():IComparator
public function set comparator(value:IComparator):void
options | property |
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.
public function get options():uint
public function set options(value:uint):void
TypedSortedList | () | Constructor |
public function TypedSortedList(wrapList:ISortedList, type:*)
Constructor, creates a new TypedList
object.
wrapList:ISortedList — the target list to wrap.
| |
type:* — the type of the elements allowed by this list.
|
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.
|
clone | () | method |
override public function clone():*
Creates and return a new TypedSortedList
object with the clone of the wrappedMap
object.
* — 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.
|
Boolean — true 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 )
|
Array —
|
sortOn | () | method |
public function sortOn(fieldName:*, options:* = null):Array
Forwards the call to wrappedList.sortOn
.
Parameters
fieldName:* | |
options:* (default = null )
|
Array —
|
subList | () | method |
override public function subList(fromIndex:int, toIndex:int):IList
Forwards the call to wrappedList.subList
.
Parameters
fromIndex:int | |
toIndex:int |
IList —
|
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