Package | org.as3collections.maps |
Class | public class SortedArrayListMap |
Inheritance | SortedArrayListMap ArrayListMap AbstractListMap Object |
Implements | ISortedMap |
sort
or sortOn
methods.
For each change that occurs the map is automatically ordered using the comparator
and options
.
If none was provided the default behavior of the sort
method is used.
sortBy
property defines whether the sorting will be made by key
or value
.
The user of this map may change their order at any time by calling the sort
or sortOn
method and imposing others arguments to change the sort behaviour.
It's possible to create typed sorted maps.
You just sends the SortedArrayListMap
object to the wrapper TypedSortedMap
or uses the MapUtil.getTypedSortedMap
.
See also
Property | Defined By | ||
---|---|---|---|
allKeysEquatable : Boolean [read-only]
Indicates whether all keys in this map implements org.as3coreaddendum.system.IEquatable interface. | AbstractListMap | ||
allValuesEquatable : Boolean [read-only]
Indicates whether all values in this map implements org.as3coreaddendum.system.IEquatable interface. | AbstractListMap | ||
comparator : IComparator
Defines the comparator object to be used automatically to sort. | SortedArrayListMap | ||
modCount : int [read-only]
The number of times this map has been structurally modified. | AbstractListMap | ||
options : uint
Defines the options to be used automatically to sort. | SortedArrayListMap | ||
sortBy : SortMapBy
Defines whether the map should be sorted by its keys or values. | SortedArrayListMap |
Method | Defined By | ||
---|---|---|---|
SortedArrayListMap(source:IMap = null, comparator:IComparator = null, options:uint = 0)
Constructor, creates a new SortedArrayListMap object. | SortedArrayListMap | ||
clear():void [override]
Removes all of the mappings from this map. | ArrayListMap | ||
clone():* [override]
Creates and return a new SortedArrayListMap object containing all elements in this map (in the same order). | SortedArrayListMap | ||
containsKey(key:*):Boolean
Returns true if this map contains a mapping for the specified key. | AbstractListMap | ||
containsValue(value:*):Boolean
Returns true if this map maps one or more keys to the specified value. | AbstractListMap | ||
Returns an ArrayList object that is a view of the mappings contained in this map (in the same order). | AbstractListMap | ||
equals(other:*):Boolean [override]
Performs an arbitrary, specific evaluation of equality between this object and the other object. | SortedArrayListMap | ||
getKeyAt(index:int):*
Returns the key at the specified position in this map. | AbstractListMap | ||
Returns an ArrayList object that is a view of the keys contained in this map. | AbstractListMap | ||
getValue(key:*):*
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key. | AbstractListMap | ||
getValueAt(index:int):*
Returns the value at the specified position in this map. | AbstractListMap | ||
Returns an ArrayList object that is a view of the values contained in this map. | AbstractListMap | ||
Returns a new IListMap object that is a view of the portion of this map whose keys are strictly less than toKey. | AbstractListMap | ||
indexOfKey(key:*):int
Returns the position of the specified key. | AbstractListMap | ||
indexOfValue(value:*):int
Returns the position of the specified value. | AbstractListMap | ||
isEmpty():Boolean
Returns true if this map contains no key-value mappings. | AbstractListMap | ||
[override]
Returns an iterator over a set of mappings. | ArrayListMap | ||
listMapIterator(index:int = 0):IListMapIterator [override]
Returns a IListMapIterator object to iterate over the mappings in this map (in proper sequence), starting at the specified position in this map. | ArrayListMap | ||
put(key:*, value:*):* [override]
Associates the specified value with the specified key in this map (optional operation). | SortedArrayListMap | ||
Copies all of the mappings from the specified map to this map (optional operation). | AbstractListMap | ||
Copies all of the mappings from the specified map to this map (optional operation). | AbstractListMap | ||
putAllByObject(o:Object):void
This implementation performs a for..in in the specified object, calling put on this map once for each iteration (optional operation). | AbstractListMap | ||
putAt(index:int, key:*, value:*):void [override]
Associates the specified value with the specified key at the specified position in this map (optional operation). | SortedArrayListMap | ||
Associates the specified entry.value with the specified entry.key in this map (optional operation). | AbstractListMap | ||
remove(key:*):* [override]
Removes the mapping for a key from this map if it is present. | ArrayListMap | ||
removeAll(keys:ICollection):Boolean
Removes the mapping for a key from this map (if it is present) for each element in the specified collection (optional operation). | AbstractListMap | ||
[override]
Removes the mapping at the specified position in this map (optional operation). | ArrayListMap | ||
removeRange(fromIndex:int, toIndex:int):IListMap [override]
Removes all of the mappings whose index is between fromIndex, inclusive, and toIndex, exclusive (optional operation). | ArrayListMap | ||
retainAll(keys:ICollection):Boolean
Retains only the mappings in this map that the keys are contained (as elements) in the specified collection (optional operation). | AbstractListMap | ||
reverse():void
Reverses the order of the mappings in this map. | AbstractListMap | ||
setKeyAt(index:int, key:*):* [override]
Replaces the key at the specified position in this map with the specified key (optional operation). | SortedArrayListMap | ||
setValueAt(index:int, value:*):* [override]
Replaces the value at the specified position in this map with the specified value (optional operation). | SortedArrayListMap | ||
size():int
Returns the number of key-value mappings in this map. | AbstractListMap | ||
sort(compare:Function = null, options:uint = 0):Array
Sorts the objects within this class. | SortedArrayListMap | ||
sortOn(fieldName:*, options:* = null):Array
Sorts the elements in an array according to one or more fields in the array. | SortedArrayListMap | ||
[override]
inheritDoc
| SortedArrayListMap | ||
Returns a new IListMap object that is a view of the portion of this map whose keys are greater than or equal to fromKey. | AbstractListMap | ||
toString():String
Returns the string representation of this instance. | AbstractListMap |
comparator | property |
comparator:IComparator
Defines the comparator object to be used automatically to sort.
If this value change the map 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 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
sortBy | property |
sortBy:SortMapBy
Defines whether the map should be sorted by its keys or values. The default is SortMapBy.KEY
.
If this value change the map is automatically reordered with the new value.
public function get sortBy():SortMapBy
public function set sortBy(value:SortMapBy):void
ArgumentError — if try to set a null value.
|
SortedArrayListMap | () | Constructor |
public function SortedArrayListMap(source:IMap = null, comparator:IComparator = null, options:uint = 0)
Constructor, creates a new SortedArrayListMap
object.
source:IMap (default = null ) — a map with wich fill this map.
| |
comparator:IComparator (default = null ) — the comparator object to be used internally to sort.
| |
options:uint (default = 0 ) — the options to be used internally to sort.
|
clone | () | method |
override public function clone():*
Creates and return a new SortedArrayListMap
object containing all elements in this map (in the same order).
* — a new SortedArrayListMap object containing all elements in this map (in the same order).
|
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.
|
put | () | method |
override public function put(key:*, value:*):*
Associates the specified value with the specified key in this map (optional operation).
If the map previously contained a mapping for the key, the old value is replaced by the specified value. (A map m
is said to contain a mapping for a key k
if and only if m.containsKey(k)
would return true
.)
Parameters
key:* — key with which the specified value is to be associated.
| |
value:* — value to be associated with the specified key.
|
* — the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)
|
putAt | () | method |
override public function putAt(index:int, key:*, value:*):void
Associates the specified value with the specified key at the specified position in this map (optional operation). Shifts the entry currently at that position (if any) and any subsequent entries to the right (adds one to their indices).
Parameters
index:int — index at which the specified entry is to be inserted.
| |
key:* — key with which the specified value is to be associated.
| |
value:* — value to be associated with the specified key.
|
setKeyAt | () | method |
override public function setKeyAt(index:int, key:*):*
Replaces the key at the specified position in this map with the specified key (optional operation).
Parameters
index:int — index of the key to replace.
| |
key:* — key to be stored at the specified position.
|
* — the key previously at the specified position.
|
setValueAt | () | method |
override public function setValueAt(index:int, value:*):*
Replaces the value at the specified position in this map with the specified value (optional operation).
Parameters
index:int — index of the value to replace.
| |
value:* — value to be stored at the specified position.
|
* — the value previously at the specified position.
|
sort | () | method |
public function sort(compare:Function = null, options:uint = 0):Array
Sorts the objects within this class.
For more info see org.as3coreaddendum.system.ISortable.sort()
in the link below.
Parameters
compare:Function (default = null )
| |
options:uint (default = 0 )
|
Array —
|
sortOn | () | method |
public function sortOn(fieldName:*, options:* = null):Array
Sorts the elements in an array according to one or more fields in the array.
Consult Array.sortOn
in the ActionScript 3.0 Language Reference in the link below for more info.
Parameters
fieldName:* | |
options:* (default = null )
|
Array —
|
See also
subMap | () | method |
override public function subMap(fromIndex:int, toIndex:int):IListMap
inheritDoc
Parameters
fromIndex:int — the index to start retrieving mappings (inclusive).
| |
toIndex:int — the index to stop retrieving mappings (exclusive).
|
IListMap — a new list that is a view of the specified range within this list.
|
org.as3coreaddendum.errors:UnsupportedOperationError — if the subMap operation is not supported by this map.
| |
IndexOutOfBoundsError — if fromIndex or toIndex is out of range (index < 0 || index > size()) .
|
import org.as3collections.ISortedMap; import org.as3collections.maps.SortedArrayListMap; 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.firstKey() // a map1.lastKey() // e map1.sortBy = SortMapBy.VALUE; map1 // {e=1,d=2,c=3,b=4,a=5} map1.firstKey() // e map1.lastKey() // a map1.sort(null, Array.NUMERIC); map1 // {e=1,d=2,c=3,b=4,a=5} map1.sort(null, Array.NUMERIC | Array.DESCENDING); map1 // {a=5,b=4,c=3,d=2,e=1} map1.sortBy = SortMapBy.KEY; map1 // {a=5,b=4,c=3,d=2,e=1} map1.headMap("d") // {a=5,b=4,c=3} map1.tailMap("b") // {b=4,c=3,d=2,e=1} map1.subMap("b", "d") // {b=4,c=3}