Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client
11g Release 1 (11.1.1)

E17503-02

oracle.adfnmc.java.util
Class TreeMap

java.lang.Object
  extended by oracle.adfnmc.java.util.AbstractMap
      extended by oracle.adfnmc.java.util.TreeMap
All Implemented Interfaces:
Serializable, Cloneable, Map, SortedMap

public class TreeMap
extends AbstractMap
implements SortedMap, Cloneable, Serializable

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.

Since:
1.2

Nested Class Summary
 
Nested classes/interfaces inherited from interface oracle.adfnmc.java.util.Map
Map.Entry
 
Constructor Summary
TreeMap()
          Constructs a new empty instance of spec.TreeMap.
TreeMap(Comparator comparator)
          Constructs a new empty instance of spec.TreeMap which uses the specified Comparator.
TreeMap(Map map)
          Constructs a new instance of spec.TreeMap containing the mappings from the specified Map and using the natural ordering.
TreeMap(SortedMap map)
          Constructs a new instance of spec.TreeMap containing the mappings from the specified SortedMap and using the same Comparator.
 
Method Summary
 void clear()
          Removes all mappings from this spec.TreeMap, leaving it empty.
 java.lang.Object clone()
          Answers a new spec.TreeMap with the same mappings, size and comparator as this spec.TreeMap.
 Comparator comparator()
          Answers the Comparator used to compare elements in this spec.TreeMap.
 boolean containsKey(java.lang.Object key)
          Searches this spec.TreeMap for the specified key.
 boolean containsValue(java.lang.Object value)
          Searches this spec.TreeMap for the specified value.
 Set entrySet()
          Answers a Set of the mappings contained in this spec.TreeMap.
 java.lang.Object firstKey()
          Answers the first sorted key in this spec.TreeMap.
 java.lang.Object get(java.lang.Object key)
          Answers the value of the mapping with the specified key.
 SortedMap headMap(java.lang.Object endKey)
          Answers a SortedMap of the specified portion of this spec.TreeMap which contains keys less than the end key.
 Set keySet()
          Answers a Set of the keys contained in this spec.TreeMap.
 java.lang.Object lastKey()
          Answer the last sorted key in this spec.TreeMap.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Maps the specified key to the specified value.
 void putAll(Map map)
          Copies every mapping in the specified Map to this spec.TreeMap.
 java.lang.Object remove(java.lang.Object key)
          Removes a mapping with the specified key from this spec.TreeMap.
 int size()
          Answers the number of mappings in this spec.TreeMap.
 SortedMap subMap(java.lang.Object startKey, java.lang.Object endKey)
          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.
 SortedMap tailMap(java.lang.Object startKey)
          Answers a SortedMap of the specified portion of this spec.TreeMap which contains keys greater or equal to the start key.
 Collection values()
          Answers a Collection of the values contained in this spec.TreeMap.
 
Methods inherited from class oracle.adfnmc.java.util.AbstractMap
equals, hashCode, isEmpty, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface oracle.adfnmc.java.util.Map
equals, hashCode, isEmpty
 

Constructor Detail

TreeMap

public TreeMap()
Constructs a new empty instance of spec.TreeMap.


TreeMap

public TreeMap(Comparator comparator)
Constructs a new empty instance of spec.TreeMap which uses the specified Comparator.

Parameters:
comparator - the Comparator

TreeMap

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

Parameters:
map - the mappings to add
Throws:
java.lang.ClassCastException - when a key in the Map does not implement the Comparable interface, or they keys in the Map cannot be compared

TreeMap

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

Parameters:
map - the mappings to add
Method Detail

clear

public void clear()
Removes all mappings from this spec.TreeMap, leaving it empty.

Specified by:
clear in interface Map
Overrides:
clear in class AbstractMap
See Also:
Map.isEmpty(), size

clone

public java.lang.Object clone()
Answers a new spec.TreeMap with the same mappings, size and comparator as this spec.TreeMap.

Overrides:
clone in class AbstractMap
Returns:
a shallow copy of this spec.TreeMap
See Also:
Cloneable

comparator

public Comparator comparator()
Answers the Comparator used to compare elements in this spec.TreeMap.

Specified by:
comparator in interface SortedMap
Returns:
a Comparator or null if the natural ordering is used

containsKey

public boolean containsKey(java.lang.Object key)
Searches this spec.TreeMap for the specified key.

Specified by:
containsKey in interface Map
Overrides:
containsKey in class AbstractMap
Parameters:
key - the object to search for
Returns:
true if key is a key of this spec.TreeMap, false otherwise
Throws:
java.lang.ClassCastException - when the key cannot be compared with the keys in this spec.TreeMap
java.lang.NullPointerException - when the key is null and the comparator cannot handle null

containsValue

public boolean containsValue(java.lang.Object value)
Searches this spec.TreeMap for the specified value.

Specified by:
containsValue in interface Map
Overrides:
containsValue in class AbstractMap
Parameters:
value - the object to search for
Returns:
true if value is a value of this spec.TreeMap, false otherwise

entrySet

public Set entrySet()
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.

Specified by:
entrySet in interface Map
Specified by:
entrySet in class AbstractMap
Returns:
a Set of the mappings

firstKey

public java.lang.Object firstKey()
Answers the first sorted key in this spec.TreeMap.

Specified by:
firstKey in interface SortedMap
Returns:
the first sorted key
Throws:
java.util.NoSuchElementException - when this spec.TreeMap is empty

get

public java.lang.Object get(java.lang.Object key)
Answers the value of the mapping with the specified key.

Specified by:
get in interface Map
Overrides:
get in class AbstractMap
Parameters:
key - the key
Returns:
the value of the mapping with the specified key
Throws:
java.lang.ClassCastException - when the key cannot be compared with the keys in this spec.TreeMap
java.lang.NullPointerException - when the key is null and the comparator cannot handle null

headMap

public SortedMap headMap(java.lang.Object endKey)
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.

Specified by:
headMap in interface SortedMap
Parameters:
endKey - the end key
Returns:
a sub-map where the keys are less than endKey
Throws:
java.lang.ClassCastException - when the end key cannot be compared with the keys in this spec.TreeMap
java.lang.NullPointerException - when the end key is null and the comparator cannot handle null

keySet

public Set keySet()
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.

Specified by:
keySet in interface Map
Overrides:
keySet in class AbstractMap
Returns:
a Set of the keys

lastKey

public java.lang.Object lastKey()
Answer the last sorted key in this spec.TreeMap.

Specified by:
lastKey in interface SortedMap
Returns:
the last sorted key
Throws:
java.util.NoSuchElementException - when this spec.TreeMap is empty

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Maps the specified key to the specified value.

Specified by:
put in interface Map
Overrides:
put in class AbstractMap
Parameters:
key - the key
value - the value
Returns:
the value of any previous mapping with the specified key or null if there was no mapping
Throws:
java.lang.ClassCastException - when the key cannot be compared with the keys in this spec.TreeMap
java.lang.NullPointerException - when the key is null and the comparator cannot handle null

putAll

public void putAll(Map map)
Copies every mapping in the specified Map to this spec.TreeMap.

Specified by:
putAll in interface Map
Overrides:
putAll in class AbstractMap
Parameters:
map - the Map to copy mappings from
Throws:
java.lang.ClassCastException - when a key in the Map cannot be compared with the keys in this spec.TreeMap
java.lang.NullPointerException - when a key in the Map is null and the comparator cannot handle null

remove

public java.lang.Object remove(java.lang.Object key)
Removes a mapping with the specified key from this spec.TreeMap.

Specified by:
remove in interface Map
Overrides:
remove in class AbstractMap
Parameters:
key - the key of the mapping to remove
Returns:
the value of the removed mapping or null if key is not a key in this spec.TreeMap
Throws:
java.lang.ClassCastException - when the key cannot be compared with the keys in this spec.TreeMap
java.lang.NullPointerException - when the key is null and the comparator cannot handle null

size

public int size()
Answers the number of mappings in this spec.TreeMap.

Specified by:
size in interface Map
Overrides:
size in class AbstractMap
Returns:
the number of mappings in this spec.TreeMap

subMap

public SortedMap subMap(java.lang.Object startKey,
                        java.lang.Object endKey)
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.

Specified by:
subMap in interface SortedMap
Parameters:
startKey - the start key
endKey - the end key
Returns:
a sub-map where the keys are greater or equal to startKey and less than endKey
Throws:
java.lang.ClassCastException - when the start or end key cannot be compared with the keys in this spec.TreeMap
java.lang.NullPointerException - when the start or end key is null and the comparator cannot handle null

tailMap

public SortedMap tailMap(java.lang.Object startKey)
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.

Specified by:
tailMap in interface SortedMap
Parameters:
startKey - the start key
Returns:
a sub-map where the keys are greater or equal to startKey
Throws:
java.lang.ClassCastException - when the start key cannot be compared with the keys in this spec.TreeMap
java.lang.NullPointerException - when the start key is null and the comparator cannot handle null

values

public Collection values()
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.

Specified by:
values in interface Map
Overrides:
values in class AbstractMap
Returns:
a Collection of the values

Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client
11g Release 1 (11.1.1)

E17503-02

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.