Packageorg.as3collections.maps
Classpublic class TypedSortedMap
InheritanceTypedSortedMap Inheritance TypedListMap Inheritance TypedMap Inheritance Object
Implements ISortedMap

TypedSortedMap works as a wrapper for a map. It stores the wrapMap constructor's argument in the wrappedMap variable. So every method call to this class is forwarded to the wrappedMap object. The methods that need to be checked for the type of the keys and values are previously validated with the validateKeyType, validateValueType or validateMap method before forward the call. If the type of a key or value requested to be inserted to this map is incompatible with the type of the map a org.as3coreaddendum.errors.ClassCastError is thrown. The calls that are forwarded to the wrappedMap returns the return of the wrappedMap call.

TypedSortedMap does not allow null keys or values.

View the examples

See also

MapUtil.getTypedSortedMap()


Public Properties
 PropertyDefined By
 InheritedallKeysEquatable : Boolean
[read-only] Indicates whether all keys in this map implements org.as3coreaddendum.system.IEquatable interface.
TypedMap
 InheritedallValuesEquatable : Boolean
[read-only] Indicates whether all values in this map implements org.as3coreaddendum.system.IEquatable interface.
TypedMap
  comparator : IComparator
Defines the wrappedMap comparator object to be used automatically to sort.
TypedSortedMap
 InheritedmodCount : int
[read-only] Returns the return of the call wrapMap.modCount.
TypedListMap
  options : uint
Defines the wrappedMap options to be used automatically to sort.
TypedSortedMap
  sortBy : SortMapBy
Defines whether the wrappedMap should be sorted by its keys or values.
TypedSortedMap
 InheritedtypeKeys : *
[read-only] Defines the acceptable type of the keys by this map.
TypedMap
 InheritedtypeValues : *
[read-only] Defines the acceptable type of the values by this map.
TypedMap
Public Methods
 MethodDefined By
  
TypedSortedMap(wrapMap:ISortedMap, typeKeys:*, typeValues:*)
Constructor, creates a new TypedSortedMap object.
TypedSortedMap
 Inherited
clear():void
Forwards the call to wrappedMap.clear.
TypedMap
  
clone():*
[override] Creates and return a new TypedSortedMap object with the clone of the wrappedMap object.
TypedSortedMap
 Inherited
containsKey(key:*):Boolean
Forwards the call to wrappedMap.containsKey.
TypedMap
 Inherited
containsValue(value:*):Boolean
Forwards the call to wrappedMap.containsValue.
TypedMap
 Inherited
Forwards the call to wrappedMap.entryCollection.
TypedMap
  
equals(other:*):Boolean
[override] Performs an arbitrary, specific evaluation of equality between this object and the other object.
TypedSortedMap
 Inherited
getKeyAt(index:int):*
Forwards the call to wrappedMap.getKeyAt.
TypedListMap
 Inherited
Forwards the call to wrappedMap.getKeys.
TypedMap
 Inherited
getValue(key:*):*
Forwards the call to wrappedMap.getValue.
TypedMap
 Inherited
getValueAt(index:int):*
Forwards the call to wrappedMap.getValueAt.
TypedListMap
 Inherited
Forwards the call to wrappedMap.getValues.
TypedMap
  
headMap(toKey:*):IListMap
[override] Forwards the call to wrappedMap.headMap.
TypedSortedMap
 Inherited
indexOfKey(key:*):int
Forwards the call to wrappedMap.indexOfKey.
TypedListMap
 Inherited
indexOfValue(value:*):int
Forwards the call to wrappedMap.indexOfValue.
TypedListMap
 Inherited
isEmpty():Boolean
Forwards the call to wrappedMap.isEmpty.
TypedMap
 Inherited
Forwards the call to wrappedMap.iterator.
TypedMap
 Inherited
Returns a IListMapIterator object to iterate over the mappings in this map (in proper sequence), starting at the specified position in this map.
TypedListMap
 Inherited
put(key:*, value:*):*
The key and value are validated with the validateKeyType and validateValueType methods to be forwarded to wrappedMap.put.
TypedMap
 Inherited
putAll(map:IMap):void
The map is validated with the validateMap method to be forwarded to wrappedMap.putAll.
TypedMap
 Inherited
putAllAt(index:int, map:IMap):void
The map is validated to be forwarded to wrappedMap.putAllAt.
TypedListMap
 Inherited
putAllByObject(o:Object):void
The objects is validated to be forwarded to wrappedMap.putAllByObject.
TypedMap
 Inherited
putAt(index:int, key:*, value:*):void
The key and value are validated to be forwarded to wrappedMap.putAt.
TypedListMap
 Inherited
The entry is validated with the validateKeyType and validateValueType methods to be forwarded to wrappedMap.putEntry.
TypedMap
 Inherited
remove(key:*):*
Forwards the call to wrappedMap.remove.
TypedMap
 Inherited
removeAll(keys:ICollection):Boolean
Forwards the call to wrappedMap.removeAll.
TypedMap
 Inherited
removeAt(index:int):IMapEntry
Forwards the call to wrappedMap.removeAt.
TypedListMap
 Inherited
removeRange(fromIndex:int, toIndex:int):IListMap
Forwards the call to wrappedMap.removeRange.
TypedListMap
 Inherited
retainAll(keys:ICollection):Boolean
Forwards the call to wrappedMap.retainAll.
TypedMap
 Inherited
reverse():void
Forwards the call to wrappedMap.reverse.
TypedListMap
 Inherited
setKeyAt(index:int, key:*):*
The key is validated to be forwarded to wrappedMap.setKeyAt.
TypedListMap
 Inherited
setValueAt(index:int, value:*):*
The value is validated to be forwarded to wrappedMap.setValueAt.
TypedListMap
 Inherited
size():int
Forwards the call to wrappedMap.size.
TypedMap
  
sort(compare:Function = null, options:uint = 0):Array
Forwards the call to wrappedMap.sort.
TypedSortedMap
  
sortOn(fieldName:*, options:* = null):Array
Forwards the call to wrappedMap.sortOn.
TypedSortedMap
  
subMap(fromIndex:int, toIndex:int):IListMap
[override] Forwards the call to wrappedMap.subMap.
TypedSortedMap
  
tailMap(fromKey:*):IListMap
[override] Forwards the call to wrappedMap.tailMap.
TypedSortedMap
 Inherited
toString():String
Returns the string representation of this instance.
TypedMap
Property Detail
comparatorproperty
comparator:IComparator

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

If this value change the wrappedMap 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 wrappedMap options to be used automatically to sort.

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


Implementation
    public function get options():uint
    public function set options(value:uint):void
sortByproperty 
sortBy:SortMapBy

Defines whether the wrappedMap should be sorted by its keys or values. The default is SortMapBy.KEY.

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


Implementation
    public function get sortBy():SortMapBy
    public function set sortBy(value:SortMapBy):void
Constructor Detail
TypedSortedMap()Constructor
public function TypedSortedMap(wrapMap:ISortedMap, typeKeys:*, typeValues:*)

Constructor, creates a new TypedSortedMap object.

Parameters
wrapMap:ISortedMap — the target map to wrap.
 
typeKeys:* — the type of the keys allowed by this map.
 
typeValues:* — the type of the values allowed by this map.

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

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

Returns
* — a new TypedSortedMap 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 mappings in the map. So, for two maps are equal the order of mappings 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.
headMap()method 
override public function headMap(toKey:*):IListMap

Forwards the call to wrappedMap.headMap.

Parameters

toKey:*

Returns
IListMap
sort()method 
public function sort(compare:Function = null, options:uint = 0):Array

Forwards the call to wrappedMap.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 wrappedMap.sortOn.

Parameters

fieldName:*
 
options:* (default = null)

Returns
Array
subMap()method 
override public function subMap(fromIndex:int, toIndex:int):IListMap

Forwards the call to wrappedMap.subMap.

Parameters

fromIndex:int
 
toIndex:int

Returns
IListMap
tailMap()method 
override public function tailMap(fromKey:*):IListMap

Forwards the call to wrappedMap.tailMap.

Parameters

fromKey:*

Returns
IListMap
Examples
     import org.as3collections.ISortedMap;
     import org.as3collections.maps.SortedArrayListMap;
     import org.as3collections.maps.TypedSortedMap;
     
     var map1:ISortedMap = new SortedArrayListMap();
     
     map1.put("e", 1)            // null
     map1.put("d", 2)            // null
     map1.put("c", 3)            // null
     map1.put("b", 4)            // null
     map1.put("a", 5)            // null
     
     map1                        // {a=5,b=4,c=3,d=2,e=1}
     map1.size()                 // 5
     
     var map2:ISortedMap = new TypedSortedMap(map1, String, Number); // you can use this way
     
     //var map2:ISortedMap = MapUtil.getTypedSortedMap(map1, String, Number); // or you can use this way
     
     map2                        // {a=5,b=4,c=3,d=2,e=1}
     map2.size()                 // 5
     
     map2.equals(map1)           // false
     
     map2.put("f", 6)            // null
     map2                        // {a=5,b=4,c=3,d=2,e=1,f=6}
     map2.size()                 // 6
     
     map2.put("g", "h")          // ClassCastError: Invalid value type. value: h | type: String | expected value type: Number
     map2.put(7, 8)              // ClassCastError: Invalid key type. key: 7 | type: int | expected key type: String