Java.Util.TreeMap Class
A map whose entries are sorted by their keys.

See Also: TreeMap Members

Syntax

[Android.Runtime.Register("java/util/TreeMap", DoNotGenerateAcw=true)]
public class TreeMap : AbstractMap, Java.IO.ISerializable, Java.Lang.ICloneable, INavigableMap, IDisposable

Remarks

A map whose entries are sorted by their keys. All optional operations such as TreeMap.put(K, V) and TreeMap.remove(java.lang.Object) are supported.

This map sorts keys using either a user-supplied comparator or the key's natural order:

With either a comparator or a natural ordering, comparisons should be consistent with equals. An ordering is consistent with equals if for every pair of keys a and b, a.equals(b) if and only if compare(a, b) == 0.

When the ordering is not consistent with equals the behavior of this class is well defined but does not honor the contract specified by Java.Util.IMap. Consider a tree map of case-insensitive strings, an ordering that is not consistent with equals:

java Example

TreeMap map = new TreeMap(String.CASE_INSENSITIVE_ORDER);
   map.put("a", "android");

   // The Map API specifies that the next line should print "null" because
   // "a".equals("A") is false and there is no mapping for upper case "A".
   // But the case insensitive ordering says compare("a", "A") == 0. TreeMap
   // uses only comparators/comparable on keys and so this prints "android".
   System.out.println(map.get("A"));
 

[Android Documentation]

Requirements

Namespace: Java.Util
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1