Packageorg.as3collections.maps
Classpublic class TypedListMap
InheritanceTypedListMap Inheritance TypedMap Inheritance Object
Implements IListMap
Subclasses TypedSortedMap

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
  modCount : int
[read-only] Returns the return of the call wrapMap.modCount.
TypedListMap
 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
  
TypedListMap(wrapMap:IListMap, typeKeys:*, typeValues:*)
Constructor, creates a new TypedSortedMap object.
TypedListMap
 Inherited
clear():void
Forwards the call to wrappedMap.clear.
TypedMap
  
clone():*
[override] Creates and return a new TypedListMap object with the clone of the wrappedMap object.
TypedListMap
 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
 Inherited
equals(other:*):Boolean
This method uses MapUtil.equalNotConsideringOrder or MapUtil.equalConsideringOrder method to perform equality, sending this map and other argument.
TypedMap
  
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
  
getValueAt(index:int):*
Forwards the call to wrappedMap.getValueAt.
TypedListMap
 Inherited
Forwards the call to wrappedMap.getValues.
TypedMap
  
headMap(toKey:*):IListMap
Forwards the call to wrappedMap.headMap.
TypedListMap
  
indexOfKey(key:*):int
Forwards the call to wrappedMap.indexOfKey.
TypedListMap
  
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
  
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
  
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
  
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
  
removeAt(index:int):IMapEntry
Forwards the call to wrappedMap.removeAt.
TypedListMap
  
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
  
reverse():void
Forwards the call to wrappedMap.reverse.
TypedListMap
  
setKeyAt(index:int, key:*):*
The key is validated to be forwarded to wrappedMap.setKeyAt.
TypedListMap
  
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
  
subMap(fromIndex:int, toIndex:int):IListMap
Forwards the call to wrappedMap.subMap.
TypedListMap
  
tailMap(fromKey:*):IListMap
Forwards the call to wrappedMap.tailMap.
TypedListMap
 Inherited
toString():String
Returns the string representation of this instance.
TypedMap
Property Detail
modCountproperty
modCount:int  [read-only]

Returns the return of the call wrapMap.modCount.


Implementation
    public function get modCount():int
Constructor Detail
TypedListMap()Constructor
public function TypedListMap(wrapMap:IListMap, typeKeys:*, typeValues:*)

Constructor, creates a new TypedSortedMap object.

Parameters
wrapMap:IListMap — 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 TypedListMap object with the clone of the wrappedMap object.

Returns
* — a new TypedListMap object with the clone of the wrappedMap object.
getKeyAt()method 
public function getKeyAt(index:int):*

Forwards the call to wrappedMap.getKeyAt.

Parameters

index:int

Returns
*
getValueAt()method 
public function getValueAt(index:int):*

Forwards the call to wrappedMap.getValueAt.

Parameters

index:int

Returns
*
headMap()method 
public function headMap(toKey:*):IListMap

Forwards the call to wrappedMap.headMap.

Parameters

toKey:*

Returns
IListMap
indexOfKey()method 
public function indexOfKey(key:*):int

Forwards the call to wrappedMap.indexOfKey.

Parameters

key:*

Returns
int
indexOfValue()method 
public function indexOfValue(value:*):int

Forwards the call to wrappedMap.indexOfValue.

Parameters

value:*

Returns
int
listMapIterator()method 
public function listMapIterator(index:int = 0):IListMapIterator

Returns a IListMapIterator object to iterate over the mappings in this map (in proper sequence), starting at the specified position in this map. The specified index indicates the first value that would be returned by an initial call to next. An initial call to previous would return the value with the specified index minus one.

This implementation always throws an UnsupportedOperationError.

Parameters

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

Returns
IListMapIterator — a IListMapIterator object to iterate over the mappings in this map (in proper sequence), starting at the specified position in this map.
putAllAt()method 
public function putAllAt(index:int, map:IMap):void

The map is validated to be forwarded to wrappedMap.putAllAt.

Parameters

index:int
 
map:IMap

putAt()method 
public function putAt(index:int, key:*, value:*):void

The key and value are validated to be forwarded to wrappedMap.putAt.

Parameters

index:int — index at which the specified mapping is to be inserted.
 
key:* — key with which the specified value is to be associated.
 
value:* — value to be associated with the specified key.


Throws
org.as3coreaddendum.errors:ClassCastError — if the type of the specified key or value is incompatible with this map.
removeAt()method 
public function removeAt(index:int):IMapEntry

Forwards the call to wrappedMap.removeAt.

Parameters

index:int

Returns
IMapEntry
removeRange()method 
public function removeRange(fromIndex:int, toIndex:int):IListMap

Forwards the call to wrappedMap.removeRange.

Parameters

fromIndex:int
 
toIndex:int

Returns
IListMap — the return of the call wrappedMap.removeRange.
reverse()method 
public function reverse():void

Forwards the call to wrappedMap.reverse.

setKeyAt()method 
public function setKeyAt(index:int, key:*):*

The key is validated to be forwarded to wrappedMap.setKeyAt.

Parameters

index:int
 
key:* — the key to forward to wrappedMap.setKeyAt.

Returns
* — the return of the call wrappedMap.setKeyAt.

Throws
org.as3coreaddendum.errors:ClassCastError — if the type of the specified key or value is incompatible with this map.
setValueAt()method 
public function setValueAt(index:int, value:*):*

The value is validated to be forwarded to wrappedMap.setValueAt.

Parameters

index:int
 
value:* — the key to forward to wrappedMap.setValueAt.

Returns
* — the return of the call wrappedMap.setValueAt.

Throws
org.as3coreaddendum.errors:ClassCastError — if the type of the specified key or value is incompatible with this map.
subMap()method 
public function subMap(fromIndex:int, toIndex:int):IListMap

Forwards the call to wrappedMap.subMap.

Parameters

fromIndex:int
 
toIndex:int

Returns
IListMap
tailMap()method 
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