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

Comparing jsr166/src/main/java/util/concurrent/ConcurrentHashMap.java (file contents):
Revision 1.83 by jsr166, Mon Aug 22 03:42:10 2005 UTC vs.
Revision 1.86 by dl, Sun Nov 20 15:38:08 2005 UTC

# Line 750 | Line 750 | public class ConcurrentHashMap<K, V> ext
750      }
751  
752      /**
753 <     * Returns the value to which this map maps the specified key, or
754 <     * <tt>null</tt> if the map contains no mapping for the key.
753 >     * Returns the value to which the specified key is mapped,
754 >     * or {@code null} if this map contains no mapping for the key.
755 >     *
756 >     * <p>More formally, if this map contains a mapping from a key
757 >     * {@code k} to a value {@code v} such that {@code key.equals(k)},
758 >     * then this method returns {@code v}; otherwise it returns
759 >     * {@code null}.  (There can be at most one such mapping.)
760       *
756     * @param key key whose associated value is to be returned
757     * @return the value to which this map maps the specified key, or
758     *         <tt>null</tt> if the map contains no mapping for the key
761       * @throws NullPointerException if the specified key is null
762       */
763      public V get(Object key) {
# Line 899 | Line 901 | public class ConcurrentHashMap<K, V> ext
901       * @param m mappings to be stored in this map
902       */
903      public void putAll(Map<? extends K, ? extends V> m) {
904 <        for (Iterator<? extends Map.Entry<? extends K, ? extends V>> it = (Iterator<? extends Map.Entry<? extends K, ? extends V>>) m.entrySet().iterator(); it.hasNext(); ) {
903 <            Entry<? extends K, ? extends V> e = it.next();
904 >        for (Map.Entry<? extends K, ? extends V> e : m.entrySet())
905              put(e.getKey(), e.getValue());
905        }
906      }
907  
908      /**
# Line 911 | Line 911 | public class ConcurrentHashMap<K, V> ext
911       *
912       * @param  key the key that needs to be removed
913       * @return the previous value associated with <tt>key</tt>, or
914 <     *         <tt>null</tt> if there was no mapping for <tt>key</tt>.
914 >     *         <tt>null</tt> if there was no mapping for <tt>key</tt>
915       * @throws NullPointerException if the specified key is null
916       */
917      public V remove(Object key) {
918 <        int hash = hash(key);
918 >        int hash = hash(key);
919          return segmentFor(hash).remove(key, hash, null);
920      }
921  
# Line 1176 | Line 1176 | public class ConcurrentHashMap<K, V> ext
1176          public void clear() {
1177              ConcurrentHashMap.this.clear();
1178          }
1179        public Object[] toArray() {
1180            Collection<K> c = new ArrayList<K>(size());
1181            for (K k : this)
1182                c.add(k);
1183            return c.toArray();
1184        }
1185        public <T> T[] toArray(T[] a) {
1186            Collection<K> c = new ArrayList<K>();
1187            for (K k : this)
1188                c.add(k);
1189            return c.toArray(a);
1190        }
1179      }
1180  
1181      final class Values extends AbstractCollection<V> {
# Line 1203 | Line 1191 | public class ConcurrentHashMap<K, V> ext
1191          public void clear() {
1192              ConcurrentHashMap.this.clear();
1193          }
1206        public Object[] toArray() {
1207            Collection<V> c = new ArrayList<V>(size());
1208            for (V v : this)
1209                c.add(v);
1210            return c.toArray();
1211        }
1212        public <T> T[] toArray(T[] a) {
1213            Collection<V> c = new ArrayList<V>(size());
1214            for (V v : this)
1215                c.add(v);
1216            return c.toArray(a);
1217        }
1194      }
1195  
1196      final class EntrySet extends AbstractSet<Map.Entry<K,V>> {
# Line 1240 | Line 1216 | public class ConcurrentHashMap<K, V> ext
1216          public void clear() {
1217              ConcurrentHashMap.this.clear();
1218          }
1243        public Object[] toArray() {
1244            Collection<Map.Entry<K,V>> c = new ArrayList<Map.Entry<K,V>>(size());
1245            for (Map.Entry<K,V> e : this)
1246                c.add(e);
1247            return c.toArray();
1248        }
1249        public <T> T[] toArray(T[] a) {
1250            Collection<Map.Entry<K,V>> c = new ArrayList<Map.Entry<K,V>>(size());
1251            for (Map.Entry<K,V> e : this)
1252                c.add(e);
1253            return c.toArray(a);
1254        }
1255
1219      }
1220  
1221      /* ---------------- Serialization Support -------------- */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines