Packagecom.yworks.bridge.util
Classpublic class TreeMap
InheritanceTreeMap Inheritance AbstractMap Inheritance YObject Inheritance Object
Implements SortedMap, Clonable

TreeMap is an implementation of SortedMap. All optional operations are supported, adding and removing. The values can be any objects. The keys can be any objects which are comparable to each other either using their natural order or a specified Comparator.



Public Properties
 PropertyDefined By
 Inheritedempty : Boolean
[read-only] Answers if this Map has no elements, a size of zero.
AbstractMap
Public Methods
 MethodDefined By
  
TreeMap(init:Boolean = true)
Constructs a new empty instance of spec.TreeMap.
TreeMap
  
clear():void
[override] Removes all mappings from this spec.TreeMap, leaving it empty.
TreeMap
  
clone():Object
[override] Answers a new spec.TreeMap with the same mappings, size and comparator as this spec.TreeMap.
TreeMap
  
Answers the Comparator used to compare elements in this spec.TreeMap.
TreeMap
  
containsKey(key:Object):Boolean
[override] Searches this spec.TreeMap for the specified key.
TreeMap
  
containsValue(value:Object):Boolean
[override] Searches this spec.TreeMap for the specified value.
TreeMap
  
[override] Answers a Set of the mappings contained in this spec.TreeMap.
TreeMap
 Inherited
equals(object:Object):Boolean
[override] Compares the specified object to this Map and answer if they are equal.
AbstractMap
  
firstKey():Object
Answers the first sorted key in this spec.TreeMap.
TreeMap
  
getClass():Class
[override]
TreeMap
  
getValue(key:Object):Object
[override] Answers the value of the mapping with the specified key.
TreeMap
 Inherited
hashCode():int
[override] Answers an integer hash code for the receiver.
AbstractMap
  
headMap(endKey:Object):SortedMap
Answers a SortedMap of the specified portion of this spec.TreeMap which contains keys less than the end key.
TreeMap
  
[override] Answers a Set of the keys contained in this spec.TreeMap.
TreeMap
  
lastKey():Object
Answer the last sorted key in this spec.TreeMap.
TreeMap
  
[static] Constructs a new empty instance of spec.TreeMap.
TreeMap
  
[static] Constructs a new empty instance of spec.TreeMap which uses the specified Comparator.
TreeMap
  
[static] Constructs a new instance of spec.TreeMap containing the mappings from the specified Map and using the natural ordering.
TreeMap
  
[static] Constructs a new instance of spec.TreeMap containing the mappings from the specified SortedMap and using the same Comparator.
TreeMap
  
putAll(map:Map):void
[override] Copies every mapping in the specified Map to this spec.TreeMap.
TreeMap
  
putValue(key:Object, value:Object):Object
[override] Maps the specified key to the specified value.
TreeMap
  
remove(key:Object):Object
[override] Removes a mapping with the specified key from this spec.TreeMap.
TreeMap
  
size():int
[override] Answers the number of mappings in this spec.TreeMap.
TreeMap
  
subMap(startKey:Object, endKey:Object):SortedMap
Answers a SortedMap of the specified portion of this spec.TreeMap which contains keys greater or equal to the start key but less than the end key.
TreeMap
  
tailMap(startKey:Object):SortedMap
Answers a SortedMap of the specified portion of this spec.TreeMap which contains keys greater or equal to the start key.
TreeMap
 Inherited
toString():String
Answers the string representation of this Map.
AbstractMap
  
[override] Answers a Collection of the values contained in this spec.TreeMap.
TreeMap
Protected Methods
 MethodDefined By
  
cloneImpl(o:Object):void
[override]
TreeMap
 Inherited
AbstractMap
  
Initializes this object.
TreeMap
  
initTreeMap2(comparator:Comparator):void
Initializes this object.
TreeMap
  
initTreeMap3(map:Map):void
Initializes this object.
TreeMap
  
Initializes this object.
TreeMap
Constructor Detail
TreeMap()Constructor
public function TreeMap(init:Boolean = true)

Constructs a new empty instance of spec.TreeMap.

Parameters
init:Boolean (default = true) — An internally used switch to help handle proper instance initialization in inheritance chains where classes can have multiple constructor-like factory methods. This parameter can safely be ignored/omitted when calling the constructor.
Method Detail
clear()method
override public function clear():void

Removes all mappings from this spec.TreeMap, leaving it empty.

See also

clone()method 
override public function clone():Object

Answers a new spec.TreeMap with the same mappings, size and comparator as this spec.TreeMap.

Returns
Object — a shallow copy of this spec.TreeMap

See also

cloneImpl()method 
override protected function cloneImpl(o:Object):void

Parameters

o:Object

comparator()method 
public function comparator():Comparator

Answers the Comparator used to compare elements in this spec.TreeMap.

Returns
Comparator — a Comparator or null if the natural ordering is used
containsKey()method 
override public function containsKey(key:Object):Boolean

Searches this spec.TreeMap for the specified key.

Parameters

key:Object — the object to search for

Returns
Boolean — true if key is a key of this spec.TreeMap, false otherwise

Throws
TypeError — when the key cannot be compared with the keys in this spec.TreeMap
 
ReferenceError — when the key is null and the comparator cannot handle null
containsValue()method 
override public function containsValue(value:Object):Boolean

Searches this spec.TreeMap for the specified value.

Parameters

value:Object — the object to search for

Returns
Boolean — true if value is a value of this spec.TreeMap, false otherwise
entrySet()method 
override public function entrySet():Set

Answers a Set of the mappings contained in this spec.TreeMap. Each element in the set is a Map.Entry. The set is backed by this spec.TreeMap so changes to one are reflected by the other. The set does not support adding.

Returns
Set — a Set of the mappings
firstKey()method 
public function firstKey():Object

Answers the first sorted key in this spec.TreeMap.

Returns
Object — the first sorted key

Throws
Error — when this spec.TreeMap is empty
getClass()method 
override public function getClass():Class

Returns
Class
getValue()method 
override public function getValue(key:Object):Object

Answers the value of the mapping with the specified key.

Parameters

key:Object — the key

Returns
Object — the value of the mapping with the specified key

Throws
TypeError — when the key cannot be compared with the keys in this spec.TreeMap
 
ReferenceError — when the key is null and the comparator cannot handle null
headMap()method 
public function headMap(endKey:Object):SortedMap

Answers a SortedMap of the specified portion of this spec.TreeMap which contains keys less than the end key. The returned SortedMap is backed by this spec.TreeMap so changes to one are reflected by the other.

Parameters

endKey:Object — the end key

Returns
SortedMap — a sub-map where the keys are less than endKey

Throws
TypeError — when the end key cannot be compared with the keys in this spec.TreeMap
 
ReferenceError — when the end key is null and the comparator cannot handle null
initTreeMap1()method 
protected final function initTreeMap1():void

Initializes this object. See the documentation of the corresponding factory method newTreeMap1() for details.

See also

initTreeMap2()method 
protected final function initTreeMap2(comparator:Comparator):void

Initializes this object. See the documentation of the corresponding factory method newTreeMap2() for details.

Parameters

comparator:Comparator

See also

initTreeMap3()method 
protected final function initTreeMap3(map:Map):void

Initializes this object. See the documentation of the corresponding factory method newTreeMap3() for details.

Parameters

map:Map

See also

initTreeMap4()method 
protected final function initTreeMap4(map:SortedMap):void

Initializes this object. See the documentation of the corresponding factory method newTreeMap4() for details.

Parameters

map:SortedMap

See also

keySet()method 
override public function keySet():Set

Answers a Set of the keys contained in this spec.TreeMap. The set is backed by this spec.TreeMap so changes to one are reflected by the other. The set does not support adding.

Returns
Set — a Set of the keys
lastKey()method 
public function lastKey():Object

Answer the last sorted key in this spec.TreeMap.

Returns
Object — the last sorted key

Throws
Error — when this spec.TreeMap is empty
newTreeMap1()method 
public static function newTreeMap1():TreeMap

Constructs a new empty instance of spec.TreeMap.

Returns
TreeMap
newTreeMap2()method 
public static function newTreeMap2(comparator:Comparator):TreeMap

Constructs a new empty instance of spec.TreeMap which uses the specified Comparator.

Parameters

comparator:Comparator — the Comparator

Returns
TreeMap
newTreeMap3()method 
public static function newTreeMap3(map:Map):TreeMap

Constructs a new instance of spec.TreeMap containing the mappings from the specified Map and using the natural ordering.

Parameters

map:Map — the mappings to add

Returns
TreeMap

Throws
TypeError — when a key in the Map does not implement the Comparable interface, or they keys in the Map cannot be compared
newTreeMap4()method 
public static function newTreeMap4(map:SortedMap):TreeMap

Constructs a new instance of spec.TreeMap containing the mappings from the specified SortedMap and using the same Comparator.

Parameters

map:SortedMap — the mappings to add

Returns
TreeMap
putAll()method 
override public function putAll(map:Map):void

Copies every mapping in the specified Map to this spec.TreeMap.

Parameters

map:Map — the Map to copy mappings from


Throws
TypeError — when a key in the Map cannot be compared with the keys in this spec.TreeMap
 
ReferenceError — when a key in the Map is null and the comparator cannot handle null
putValue()method 
override public function putValue(key:Object, value:Object):Object

Maps the specified key to the specified value.

Parameters

key:Object — the key
 
value:Object — the value

Returns
Object — the value of any previous mapping with the specified key or null if there was no mapping

Throws
TypeError — when the key cannot be compared with the keys in this spec.TreeMap
 
ReferenceError — when the key is null and the comparator cannot handle null
remove()method 
override public function remove(key:Object):Object

Removes a mapping with the specified key from this spec.TreeMap.

Parameters

key:Object — the key of the mapping to remove

Returns
Object — the value of the removed mapping or null if key is not a key in this spec.TreeMap

Throws
TypeError — when the key cannot be compared with the keys in this spec.TreeMap
 
ReferenceError — when the key is null and the comparator cannot handle null
size()method 
override public function size():int

Answers the number of mappings in this spec.TreeMap.

Returns
int — the number of mappings in this spec.TreeMap
subMap()method 
public function subMap(startKey:Object, endKey:Object):SortedMap

Answers a SortedMap of the specified portion of this spec.TreeMap which contains keys greater or equal to the start key but less than the end key. The returned SortedMap is backed by this spec.TreeMap so changes to one are reflected by the other.

Parameters

startKey:Object — the start key
 
endKey:Object — the end key

Returns
SortedMap — a sub-map where the keys are greater or equal to startKey and less than endKey

Throws
TypeError — when the start or end key cannot be compared with the keys in this spec.TreeMap
 
ReferenceError — when the start or end key is null and the comparator cannot handle null
tailMap()method 
public function tailMap(startKey:Object):SortedMap

Answers a SortedMap of the specified portion of this spec.TreeMap which contains keys greater or equal to the start key. The returned SortedMap is backed by this spec.TreeMap so changes to one are reflected by the other.

Parameters

startKey:Object — the start key

Returns
SortedMap — a sub-map where the keys are greater or equal to startKey

Throws
TypeError — when the start key cannot be compared with the keys in this spec.TreeMap
 
ReferenceError — when the start key is null and the comparator cannot handle null
values()method 
override public function values():Collection

Answers a Collection of the values contained in this spec.TreeMap. The collection is backed by this spec.TreeMap so changes to one are reflected by the other. The collection does not support adding.

Returns
Collection — a Collection of the values