ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/TreeMap.java
(Generate patch)

Comparing jsr166/src/main/java/util/TreeMap.java (file contents):
Revision 1.16 by dl, Wed May 25 14:05:06 2005 UTC vs.
Revision 1.21 by jsr166, Fri Jun 24 00:26:57 2005 UTC

# Line 6 | Line 6
6   */
7  
8   package java.util;
9 + import java.util.*; // for javadoc (till 6280605 is fixed)
10  
11   /**
12   * A Red-Black tree based {@link NavigableMap} implementation.
# Line 216 | Line 217 | public class TreeMap<K,V>
217       * specified value.  More formally, returns <tt>true</tt> if and only if
218       * this map contains at least one mapping to a value <tt>v</tt> such
219       * that <tt>(value==null ? v==null : value.equals(v))</tt>.  This
220 <     * operation requires time linear in the map size.
220 >     * operation will probably require time linear in the map size for
221 >     * most implementations.
222       *
223       * @param value value whose presence in this map is to be tested
224       * @return <tt>true</tt> if a mapping to <tt>value</tt> exists;
# Line 253 | Line 255 | public class TreeMap<K,V>
255       * <tt>null</tt> if the map contains no mapping for the key.  A return
256       * value of <tt>null</tt> does not <i>necessarily</i> indicate that the
257       * map contains no mapping for the key; it's also possible that the map
258 <     * explicitly maps the key to <tt>null</tt>.  The {@link #containsKey}
259 <     * operation may be used to distinguish these two cases.
258 >     * explicitly maps the key to <tt>null</tt>.  The {@link #containsKey
259 >     * containsKey} operation may be used to distinguish these two cases.
260       *
261       * @param key key whose associated value is to be returned
262       * @return the value to which this map maps the specified key, or
# Line 519 | Line 521 | public class TreeMap<K,V>
521  
522      /**
523       * Associates the specified value with the specified key in this map.
524 <     * If the map previously contained a mapping for this key, the old
524 >     * If the map previously contained a mapping for the key, the old
525       * value is replaced.
526       *
527       * @param key key with which the specified value is to be associated
# Line 1066 | Line 1068 | public class TreeMap<K,V>
1068          }
1069  
1070          public boolean containsKey(Object key) {
1071 <            return inRange((K) key) && TreeMap.this.containsKey(key);
1071 >            return inRange(key) && TreeMap.this.containsKey(key);
1072          }
1073  
1074          public V get(Object key) {
1075 <            if (!inRange((K) key))
1075 >            if (!inRange(key))
1076                  return null;
1077              return TreeMap.this.get(key);
1078          }
# Line 1082 | Line 1084 | public class TreeMap<K,V>
1084          }
1085  
1086          public V remove(Object key) {
1087 <            if (!inRange((K) key))
1087 >            if (!inRange(key))
1088                  return null;
1089              return TreeMap.this.remove(key);
1090          }
# Line 1351 | Line 1353 | public class TreeMap<K,V>
1353              return navigableTailMap(fromKey);
1354          }
1355  
1356 <        private boolean inRange(K key) {
1356 >        private boolean inRange(Object key) {
1357              return (fromStart || compare(key, fromKey) >= 0) &&
1358                     (toEnd     || compare(key, toKey)   <  0);
1359          }
1360  
1361          // This form allows the high endpoint (as well as all legit keys)
1362 <        private boolean inRange2(K key) {
1362 >        private boolean inRange2(Object key) {
1363              return (fromStart || compare(key, fromKey) >= 0) &&
1364                     (toEnd     || compare(key, toKey)   <= 0);
1365          }
# Line 1519 | Line 1521 | public class TreeMap<K,V>
1521      }
1522  
1523      /**
1524 <     * Test two values  for equality.  Differs from o1.equals(o2) only in
1524 >     * Test two values for equality.  Differs from o1.equals(o2) only in
1525       * that it copes with <tt>null</tt> o1 properly.
1526       */
1527      private static boolean valEquals(Object o1, Object o2) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines