/** * Copies all of the mappings from the given map to this * <tt>IdentityWeakHashMap</tt>, replacing any existing mappings. * * @param m mappings to be stored in this <tt>IdentityWeakHashMap</tt>. * @throws <tt>NullPointerException</tt> if m is null. */ public void putAll(Map<? extends K, ? extends V> m) { if (m == null) { throw new NullPointerException(); } Iterator<? extends Entry<? extends K, ? extends V>> i = m.entrySet().iterator(); while (i.hasNext()) { Map.Entry<? extends K, ? extends V> me = i.next(); put(me.getKey(), me.getValue()); } }
/** * Copies all of the mappings from the given map to this * <tt>IdentityWeakHashMap</tt>, replacing any existing mappings. * * @param m mappings to be stored in this <tt>IdentityWeakHashMap</tt>. * @throws <tt>NullPointerException</tt> if m is null. */ public void putAll(Map<? extends K, ? extends V> m) { if (m == null) { throw new NullPointerException(); } Iterator<? extends Entry<? extends K, ? extends V>> i = m.entrySet().iterator(); while (i.hasNext()) { Map.Entry<? extends K, ? extends V> me = i.next(); put(me.getKey(), me.getValue()); } }
/** * Copies all of the mappings from the given map to this * <tt>IdentityWeakHashMap</tt>, replacing any existing mappings. * * @param m mappings to be stored in this <tt>IdentityWeakHashMap</tt>. * @throws <tt>NullPointerException</tt> if m is null. */ public void putAll(Map<? extends K, ? extends V> m) { if (m == null) { throw new NullPointerException(); } Iterator<? extends Entry<? extends K, ? extends V>> i = m.entrySet().iterator(); while (i.hasNext()) { Map.Entry<? extends K, ? extends V> me = i.next(); put(me.getKey(), me.getValue()); } }
/** * Deserialize the <tt>IdentityWeakHashMap</tt> from a stream. */ private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { // Read in the threshold, loadfactor (and any hidden 'magic' stuff). s.defaultReadObject(); // Read in number of buckets and allocate the bucket array; int numBuckets = s.readInt(); entries = new WeakEntry[numBuckets]; // Read in size (count) int size = s.readInt(); // Read the mappings and add to the IdentityWeakHashMap for (int i = 0; i < size; i++) { Object key = s.readObject(); Object value = s.readObject(); //only re-add if not null as could have been garbage collected at any time //before the writeObject if (key != null && value != null){ put((K)key, (V)value); } } } }
/** * Deserialize the <tt>IdentityWeakHashMap</tt> from a stream. */ private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { // Read in the threshold, loadfactor (and any hidden 'magic' stuff). s.defaultReadObject(); // Read in number of buckets and allocate the bucket array; int numBuckets = s.readInt(); entries = new WeakEntry[numBuckets]; // Read in size (count) int size = s.readInt(); // Read the mappings and add to the IdentityWeakHashMap for (int i = 0; i < size; i++) { Object key = s.readObject(); Object value = s.readObject(); //only re-add if not null as could have been garbage collected at any time //before the writeObject if (key != null && value != null){ put((K)key, (V)value); } } } }
/** * Deserialize the <tt>IdentityWeakHashMap</tt> from a stream. */ private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { // Read in the threshold, loadfactor (and any hidden 'magic' stuff). s.defaultReadObject(); // Read in number of buckets and allocate the bucket array; int numBuckets = s.readInt(); entries = new WeakEntry[numBuckets]; // Read in size (count) int size = s.readInt(); // Read the mappings and add to the IdentityWeakHashMap for (int i = 0; i < size; i++) { Object key = s.readObject(); Object value = s.readObject(); //only re-add if not null as could have been garbage collected at any time //before the writeObject if (key != null && value != null){ put((K)key, (V)value); } } } }