Package | org.as3collections.maps |
Class | public class TypedSortedMap |
Inheritance | TypedSortedMap TypedListMap TypedMap 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.
See also
Property | Defined By | ||
---|---|---|---|
allKeysEquatable : Boolean [read-only]
Indicates whether all keys in this map implements org.as3coreaddendum.system.IEquatable interface. | TypedMap | ||
allValuesEquatable : 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 | ||
modCount : 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 | ||
typeKeys : * [read-only]
Defines the acceptable type of the keys by this map. | TypedMap | ||
typeValues : * [read-only]
Defines the acceptable type of the values by this map. | TypedMap |
Method | Defined By | ||
---|---|---|---|
TypedSortedMap(wrapMap:ISortedMap, typeKeys:*, typeValues:*)
Constructor, creates a new TypedSortedMap object. | TypedSortedMap | ||
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 | ||
containsKey(key:*):Boolean
Forwards the call to wrappedMap.containsKey. | TypedMap | ||
containsValue(value:*):Boolean
Forwards the call to wrappedMap.containsValue. | TypedMap | ||
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 | ||
getKeyAt(index:int):*
Forwards the call to wrappedMap.getKeyAt. | TypedListMap | ||
Forwards the call to wrappedMap.getKeys. | TypedMap | ||
getValue(key:*):*
Forwards the call to wrappedMap.getValue. | TypedMap | ||
getValueAt(index:int):*
Forwards the call to wrappedMap.getValueAt. | TypedListMap | ||
Forwards the call to wrappedMap.getValues. | TypedMap | ||
[override]
Forwards the call to wrappedMap.headMap. | TypedSortedMap | ||
indexOfKey(key:*):int
Forwards the call to wrappedMap.indexOfKey. | TypedListMap | ||
indexOfValue(value:*):int
Forwards the call to wrappedMap.indexOfValue. | TypedListMap | ||
isEmpty():Boolean
Forwards the call to wrappedMap.isEmpty. | TypedMap | ||
Forwards the call to wrappedMap.iterator. | TypedMap | ||
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. | TypedListMap | ||
put(key:*, value:*):*
The key and value are validated with the validateKeyType and validateValueType methods to be forwarded to wrappedMap.put. | TypedMap | ||
The map is validated with the validateMap method to be forwarded to wrappedMap.putAll. | TypedMap | ||
The map is validated to be forwarded to wrappedMap.putAllAt. | TypedListMap | ||
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 | ||
The entry is validated with the validateKeyType and validateValueType methods to be forwarded to wrappedMap.putEntry. | TypedMap | ||
remove(key:*):*
Forwards the call to wrappedMap.remove. | TypedMap | ||
removeAll(keys:ICollection):Boolean
Forwards the call to wrappedMap.removeAll. | TypedMap | ||
Forwards the call to wrappedMap.removeAt. | TypedListMap | ||
removeRange(fromIndex:int, toIndex:int):IListMap
Forwards the call to wrappedMap.removeRange. | TypedListMap | ||
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 | ||
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 | ||
[override]
Forwards the call to wrappedMap.subMap. | TypedSortedMap | ||
[override]
Forwards the call to wrappedMap.tailMap. | TypedSortedMap | ||
toString():String
Returns the string representation of this instance. | TypedMap |
comparator | property |
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.
public function get comparator():IComparator
public function set comparator(value:IComparator):void
options | property |
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.
public function get options():uint
public function set options(value:uint):void
sortBy | property |
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.
public function get sortBy():SortMapBy
public function set sortBy(value:SortMapBy):void
TypedSortedMap | () | Constructor |
public function TypedSortedMap(wrapMap:ISortedMap, typeKeys:*, typeValues:*)
Constructor, creates a new TypedSortedMap
object.
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.
|
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.
|
clone | () | method |
override public function clone():*
Creates and return a new TypedSortedMap
object with the clone of the wrappedMap
object.
* — 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.
|
Boolean — true if the arbitrary evaluation considers the objects equal.
|
headMap | () | method |
override public function headMap(toKey:*):IListMap
Forwards the call to wrappedMap.headMap
.
Parameters
toKey:* |
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 )
|
Array —
|
sortOn | () | method |
public function sortOn(fieldName:*, options:* = null):Array
Forwards the call to wrappedMap.sortOn
.
Parameters
fieldName:* | |
options:* (default = null )
|
Array —
|
subMap | () | method |
override public function subMap(fromIndex:int, toIndex:int):IListMap
Forwards the call to wrappedMap.subMap
.
Parameters
fromIndex:int | |
toIndex:int |
IListMap —
|
tailMap | () | method |
override public function tailMap(fromKey:*):IListMap
Forwards the call to wrappedMap.tailMap
.
Parameters
fromKey:* |
IListMap —
|
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