jdk/src/share/classes/java/util/WeakHashMap.java
changeset 7803 56bc97d69d93
parent 5506 202f599c92aa
child 9035 1255eb81cc2f
equal deleted inserted replaced
7802:74f2ee2b62ba 7803:56bc97d69d93
   169     private final float loadFactor;
   169     private final float loadFactor;
   170 
   170 
   171     /**
   171     /**
   172      * Reference queue for cleared WeakEntries
   172      * Reference queue for cleared WeakEntries
   173      */
   173      */
   174     private final ReferenceQueue<Object> queue = new ReferenceQueue<Object>();
   174     private final ReferenceQueue<Object> queue = new ReferenceQueue<>();
   175 
   175 
   176     /**
   176     /**
   177      * The number of times this WeakHashMap has been structurally modified.
   177      * The number of times this WeakHashMap has been structurally modified.
   178      * Structural modifications are those that change the number of
   178      * Structural modifications are those that change the number of
   179      * mappings in the map or otherwise modify its internal structure
   179      * mappings in the map or otherwise modify its internal structure
   437             }
   437             }
   438         }
   438         }
   439 
   439 
   440         modCount++;
   440         modCount++;
   441         Entry<K,V> e = tab[i];
   441         Entry<K,V> e = tab[i];
   442         tab[i] = new Entry<K,V>(k, value, queue, h, e);
   442         tab[i] = new Entry<>(k, value, queue, h, e);
   443         if (++size >= threshold)
   443         if (++size >= threshold)
   444             resize(tab.length * 2);
   444             resize(tab.length * 2);
   445         return null;
   445         return null;
   446     }
   446     }
   447 
   447 
   953         public void clear() {
   953         public void clear() {
   954             WeakHashMap.this.clear();
   954             WeakHashMap.this.clear();
   955         }
   955         }
   956 
   956 
   957         private List<Map.Entry<K,V>> deepCopy() {
   957         private List<Map.Entry<K,V>> deepCopy() {
   958             List<Map.Entry<K,V>> list =
   958             List<Map.Entry<K,V>> list = new ArrayList<>(size());
   959                 new ArrayList<Map.Entry<K,V>>(size());
       
   960             for (Map.Entry<K,V> e : this)
   959             for (Map.Entry<K,V> e : this)
   961                 list.add(new AbstractMap.SimpleEntry<K,V>(e));
   960                 list.add(new AbstractMap.SimpleEntry<>(e));
   962             return list;
   961             return list;
   963         }
   962         }
   964 
   963 
   965         public Object[] toArray() {
   964         public Object[] toArray() {
   966             return deepCopy().toArray();
   965             return deepCopy().toArray();