API Overview API Index Package Overview Direct link to this page
JDK 1.6
  java.util. TreeMap View Source
Author(s)
Josh Bloch and Doug Lea
Since
1.2
Version
1.73, 05/10/06
Serial
Hierarchy
 Object
      AbstractMap
          TreeMap
Implements
 NavigableMap
 Cloneable
 Serializable
Subclasses
Description
public class TreeMap
  A Red-Black tree based NavigableMap implementation.
Constructors
public TreeMap ()
  Constructs a new, empty tree map, using the natural ordering of its keys.
public TreeMap (Comparator<Object> comparator)
  Constructs a new, empty tree map, ordered according to the given comparator.
public TreeMap (Map<Object, Object> m)
  Constructs a new tree map containing the same mappings as the given map, ordered according to the natural ordering of its keys.
public TreeMap (SortedMap< K, Object> m)
  Constructs a new tree map containing the same mappings and using the same ordering as the specified sorted map.
Methods
Hide/Show inherited methods
pack-private void addAllForTreeSet (SortedSet<Object> set, V defaultVal)
Intended to be called only from TreeSet.addAll
public Entry< K, V> ceilingEntry ( K key) [Specified in NavigableMap]
 
public K ceilingKey ( K key) [Specified in NavigableMap]
 
public void clear () [Overrides AbstractMap]
  Removes all of the mappings from this map.
public Object clone () [Overrides AbstractMap]
  Returns a shallow copy of this TreeMap instance.
public Comparator<Object> comparator ()
pack-privatefinal int compare (Object k1, Object k2)
Compares two keys using the correct comparison method for this TreeMap.
public boolean containsKey (Object key) [Overrides AbstractMap]
  Returns true if this map contains a mapping for the specified key.
public boolean containsValue (Object value) [Overrides AbstractMap]
  Returns true if this map maps one or more keys to the specified value.
pack-private Iterator< K> descendingKeyIterator ()
public NavigableSet< K> descendingKeySet () [Specified in NavigableMap]
 
public NavigableMap< K, V> descendingMap () [Specified in NavigableMap]
 
public Set<Entry< K, V>> entrySet () [Specified in AbstractMap]
  Returns a Set view of the mappings contained in this map.
public boolean equals (Object o) [Inherited From AbstractMap]
  Compares the specified object with this map for equality.
pack-privatestatic Entry< K, V> exportEntry (Entry< K, V> e)
Return SimpleImmutableEntry for entry, or null if null
public Entry< K, V> firstEntry () [Specified in NavigableMap]
 
public K firstKey ()
 
public Entry< K, V> floorEntry ( K key) [Specified in NavigableMap]
 
public K floorKey ( K key) [Specified in NavigableMap]
 
public V get (Object key) [Overrides AbstractMap]
  Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
pack-privatefinal Entry< K, V> getCeilingEntry ( K key)
Gets the entry corresponding to the specified key; if no such entry exists, returns the entry for the least key greater than the specified key; if no such entry exists (i.e., the greatest key in the Tree is less than the specified key), returns null.
pack-privatefinal Entry< K, V> getEntry (Object key)
  Returns this map's entry for the given key, or null if the map does not contain an entry for the key.
pack-privatefinal Entry< K, V> getEntryUsingComparator (Object key)
  Version of getEntry using comparator.
pack-privatefinal Entry< K, V> getFirstEntry ()
  Returns the first Entry in the TreeMap (according to the TreeMap's key-sort function).
pack-privatefinal Entry< K, V> getFloorEntry ( K key)
Gets the entry corresponding to the specified key; if no such entry exists, returns the entry for the greatest key less than the specified key; if no such entry exists, returns null.
pack-privatefinal Entry< K, V> getHigherEntry ( K key)
Gets the entry for the least key greater than the specified key; if no such entry exists, returns the entry for the least key greater than the specified key; if no such entry exists returns null.
pack-privatefinal Entry< K, V> getLastEntry ()
  Returns the last Entry in the TreeMap (according to the TreeMap's key-sort function).
pack-privatefinal Entry< K, V> getLowerEntry ( K key)
Returns the entry for the greatest key less than the specified key; if no such entry exists (i.e., the least key in the Tree is greater than the specified key), returns null.
public int hashCode () [Inherited From AbstractMap]
  Returns the hash code value for this map.
public SortedMap< K, V> headMap ( K toKey) [Specified in NavigableMap]
 
public NavigableMap< K, V> headMap ( K toKey, boolean inclusive) [Specified in NavigableMap]
 
public Entry< K, V> higherEntry ( K key) [Specified in NavigableMap]
 
public K higherKey ( K key) [Specified in NavigableMap]
 
public boolean isEmpty () [Inherited From AbstractMap]
  Returns true if this map contains no key-value mappings.
pack-privatestatic K key (Entry< K, Object> e)
  Returns the key corresponding to the specified Entry.
pack-private Iterator< K> keyIterator ()
pack-privatestatic K keyOrNull (Entry< K, V> e)
Return key for entry, or null if null
public Set< K> keySet () [Overrides AbstractMap]
  Returns a Set view of the keys contained in this map.
public Entry< K, V> lastEntry () [Specified in NavigableMap]
 
public K lastKey ()
 
public Entry< K, V> lowerEntry ( K key) [Specified in NavigableMap]
 
public K lowerKey ( K key) [Specified in NavigableMap]
 
public NavigableSet< K> navigableKeySet () [Specified in NavigableMap]
 
public Entry< K, V> pollFirstEntry () [Specified in NavigableMap]
 
public Entry< K, V> pollLastEntry () [Specified in NavigableMap]
 
pack-privatestatic Entry< K, V> predecessor (Entry< K, V> t)
Returns the predecessor of the specified Entry, or null if no such.
public V put ( K key, V value) [Overrides AbstractMap]
  Associates the specified value with the specified key in this map.
public void putAll (Map<Object, Object> map) [Overrides AbstractMap]
  Copies all of the mappings from the specified map to this map.
pack-private void readTreeSet (int size, ObjectInputStream s, V defaultVal) throws IOException ClassNotFoundException
Intended to be called only from TreeSet.readObject
public V remove (Object key) [Overrides AbstractMap]
  Removes the mapping for this key from this TreeMap if present.
public int size () [Overrides AbstractMap]
  Returns the number of key-value mappings in this map.
public NavigableMap< K, V> subMap ( K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) [Specified in NavigableMap]
 
public SortedMap< K, V> subMap ( K fromKey, K toKey) [Specified in NavigableMap]
 
pack-privatestatic Entry< K, V> successor (Entry< K, V> t)
Returns the successor of the specified Entry, or null if no such.
public SortedMap< K, V> tailMap ( K fromKey) [Specified in NavigableMap]
 
public NavigableMap< K, V> tailMap ( K fromKey, boolean inclusive) [Specified in NavigableMap]
 
public String toString () [Inherited From AbstractMap]
  Returns a string representation of this map.
pack-privatefinalstatic boolean valEquals (Object o1, Object o2)
  Test two values for equality.
public Collection< V> values () [Overrides AbstractMap]
  Returns a Collection view of the values contained in this map.
Fields
Hide/Show inherited fields
pack-privatetransientvolatile Set< K> keySet [Inherited From AbstractMap]
  Each of these fields are initialized to contain an instance of the appropriate view the first time this view is requested.
pack-privatetransientvolatile Collection< V> values [Inherited From AbstractMap]
Nested Classes
  TreeMap.Values
  TreeMap.EntrySet
  TreeMap.KeySet
  TreeMap.PrivateEntryIterator
Base class for TreeMap Iterators
  TreeMap.EntryIterator
  TreeMap.ValueIterator
  TreeMap.KeyIterator
  TreeMap.DescendingKeyIterator
  TreeMap.NavigableSubMap
  TreeMap.AscendingSubMap
  TreeMap.DescendingSubMap
  TreeMap.Entry
Node in the Tree.
  AbstractMap.SimpleEntry
An Entry maintaining a key and a value.
  AbstractMap.SimpleImmutableEntry
An Entry maintaining an immutable key and value.
Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar