KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > internal > helper > TopLinkIdentityHashMap


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2005, Oracle. All rights reserved.
22
package oracle.toplink.essentials.internal.helper;
23
24
25 /**
26  * INTERNAL:
27  * <p>
28  * <b>Purpose</b>: Define a {@link Map} that manages key equality by reference,
29  * not equals(). This is required to track objects throughout the lifecycle
30  * of a {@link oracle.toplink.essentials.sessions.UnitOfWork}, regardless if the domain
31  * object redefines its equals() method. Additionally, this implementation does
32  * <b>not</b> permit nulls.
33  *
34  * @author Mike Norman (since TopLink 10.1.3)
35  *
36  */

37
38 // J2SE imports
39
import java.io.*;
40 import java.util.*;
41
42 public class TopLinkIdentityHashMap extends AbstractMap implements Map, Cloneable JavaDoc, Serializable {
43     static final long serialVersionUID = -5176951017503351630L;
44
45     // the default initial capacity
46
static final int DEFAULT_INITIAL_CAPACITY = 32;
47
48     // the maximum capacity.
49
static final int MAXIMUM_CAPACITY = 1 << 30;
50
51     // the loadFactor used when none specified in constructor.
52
static final float DEFAULT_LOAD_FACTOR = 0.75f;
53     protected transient Entry[] entries;// internal array of Entry's
54
protected transient int count = 0;
55     private transient int modCount = 0;// # of times this Map has been modified
56
protected int threshold = 0;
57     protected float loadFactor = 0;
58
59     /**
60      * Constructs a new <tt>TopLinkIdentityHashMap</tt> with the given
61      * initial capacity and the given loadFactor.
62      *
63      * @param initialCapacity the initial capacity of this
64      * <tt>TopLinkIdentityHashMap</tt>.
65      * @param loadFactor the loadFactor of the <tt>TopLinkIdentityHashMap</tt>.
66      * @throws IllegalArgumentException if the initial capacity is less
67      * than zero, or if the loadFactor is nonpositive.
68      */

69     public TopLinkIdentityHashMap(int initialCapacity, float loadFactor) {
70         if (initialCapacity < 0) {
71             throw new IllegalArgumentException JavaDoc("Illegal initialCapacity: " + initialCapacity);
72         }
73         if (initialCapacity > MAXIMUM_CAPACITY) {
74             initialCapacity = MAXIMUM_CAPACITY;
75         }
76         if ((loadFactor <= 0) || Float.isNaN(loadFactor)) {
77             throw new IllegalArgumentException JavaDoc("Illegal loadFactor: " + loadFactor);
78         }
79
80         // Find a power of 2 >= initialCapacity
81
int capacity = 1;
82         while (capacity < initialCapacity) {
83             capacity <<= 1;
84         }
85         this.loadFactor = loadFactor;
86         threshold = (int)(capacity * loadFactor);
87         entries = new Entry[capacity];
88     }
89
90     /**
91      * Constructs a new <tt>TopLinkIdentityHashMap</tt> with the given
92      * initial capacity and a default loadFactor of <tt>0.75</tt>.
93      *
94      * @param initialCapacity the initial capacity of the
95      * <tt>TopLinkIdentityHashMap</tt>.
96      * @throws <tt>IllegalArgumentException</tt> if the initial capacity is less
97      * than zero.
98      */

99     public TopLinkIdentityHashMap(int initialCapacity) {
100         this(initialCapacity, DEFAULT_LOAD_FACTOR);
101     }
102
103     /**
104      * Constructs a new <tt>TopLinkIdentityHashMap</tt> with a default initial
105      * capacity of <tt>32</tt> and a loadfactor of <tt>0.75</tt>.
106      */

107     public TopLinkIdentityHashMap() {
108         loadFactor = DEFAULT_LOAD_FACTOR;
109         threshold = (int)(DEFAULT_INITIAL_CAPACITY * DEFAULT_LOAD_FACTOR);
110         entries = new Entry[DEFAULT_INITIAL_CAPACITY];
111     }
112
113     /**
114      * Constructs a new <tt>TopLinkIdentityHashMap</tt> with the same mappings
115      * as the given map. The <tt>TopLinkIdentityHashMap</tt> is created with a
116      * capacity sufficient to hold the elements of the given map.
117      *
118      * @param m the map whose mappings are to be placed in the
119      * <tt>TopLinkIdentityHashMap</tt>.
120      */

121     public TopLinkIdentityHashMap(Map m) {
122         this(Math.max((int)(m.size() / DEFAULT_LOAD_FACTOR) + 1, DEFAULT_INITIAL_CAPACITY), DEFAULT_LOAD_FACTOR);
123         putAll(m);
124     }
125
126     /**
127      * @return the size of this <tt>TopLinkIdentityHashMap</tt>.
128      */

129     public int size() {
130         return count;
131     }
132
133     /**
134      * @return <tt>true</tt> if this <tt>TopLinkIdentityHashMap</tt> is empty.
135      */

136     public boolean isEmpty() {
137         return (count == 0);
138     }
139
140     /**
141      * Returns <tt>true</tt> if this <tt>TopLinkIdentityHashMap</tt> contains
142      * the given object. Equality is tested by the equals() method.
143      *
144      * @param obj the object to find.
145      * @return <tt>true</tt> if this <tt>TopLinkIdentityHashMap</tt> contains
146      * obj.
147      * @throws <tt>NullPointerException</tt> if obj is null</tt>.
148      */

149     public boolean containsValue(Object JavaDoc obj) {
150         if (obj == null) {
151             throw new NullPointerException JavaDoc();
152         }
153
154         Entry[] copyOfEntries = entries;
155         for (int i = copyOfEntries.length; i-- > 0;) {
156             for (Entry e = copyOfEntries[i]; e != null; e = e.next) {
157                 if (e.value.equals(obj)) {
158                     return true;
159                 }
160             }
161         }
162         return false;
163     }
164
165     /**
166      * Returns <tt>true</tt> if this <tt>TopLinkIdentityHashMap</tt> contains a
167      * mapping for the given key. Equality is tested by reference.
168      *
169      * @param key object to be used as a key into this
170      * <tt>TopLinkIdentityHashMap</tt>.
171      * @return <tt>true</tt> if this <tt>TopLinkIdentityHashMap</tt> contains a
172      * mapping for key.
173      */

174     public boolean containsKey(Object JavaDoc key) {
175         Entry[] copyOfEntries = entries;
176         int hash = System.identityHashCode(key);
177         int index = (hash & 0x7FFFFFFF) % copyOfEntries.length;
178         for (Entry e = copyOfEntries[index]; e != null; e = e.next) {
179             if (e.key == key) {
180                 return true;
181             }
182         }
183         return false;
184     }
185
186     /**
187      * Returns the value to which the given key is mapped in this
188      * <tt>TopLinkIdentityHashMap</tt>. Returns <tt>null</tt> if this
189      * <tt>TopLinkIdentityHashMap</tt> contains no mapping for this key.
190      *
191      * @return the value to which this <tt>TopLinkIdentityHashMap</tt> maps the
192      * given key.
193      * @param key key whose associated value is to be returned.
194      */

195     public Object JavaDoc get(Object JavaDoc key) {
196         Entry[] copyOfEntries = entries;
197         int hash = System.identityHashCode(key);
198         int index = (hash & 0x7FFFFFFF) % copyOfEntries.length;
199         for (Entry e = copyOfEntries[index]; e != null; e = e.next) {
200             if (e.key == key) {
201                 return e.value;
202             }
203         }
204         return null;
205     }
206
207     /**
208      * INTERNAL:
209      * Re-builds the internal array of Entry's with a larger capacity.
210      * This method is called automatically when the number of objects in this
211      * TopLinkIdentityHashMap exceeds its current threshold.
212      */

213     private void rehash() {
214         int oldCapacity = entries.length;
215         Entry[] oldEntries = entries;
216         int newCapacity = (oldCapacity * 2) + 1;
217         Entry[] newEntries = new Entry[newCapacity];
218         modCount++;
219         threshold = (int)(newCapacity * loadFactor);
220         entries = newEntries;
221         for (int i = oldCapacity; i-- > 0;) {
222             for (Entry old = oldEntries[i]; old != null;) {
223                 Entry e = old;
224                 old = old.next;
225                 int index = (e.hash & 0x7FFFFFFF) % newCapacity;
226                 e.next = newEntries[index];
227                 newEntries[index] = e;
228             }
229         }
230     }
231
232     /**
233      * Associate the given object with the given key in this
234      * <tt>TopLinkIdentityHashMap</tt>, replacing any existing mapping.
235      *
236      * @param key key to map to given object.
237      * @param obj object to be associated with key.
238      * @return the previous object for key or <tt>null</tt> if this
239      * <tt>TopLinkIdentityHashMap</tt> did not have one.
240      * @throws <tt>NullPointerException</tt> if obj is null</tt>.
241      */

242     public Object JavaDoc put(Object JavaDoc key, Object JavaDoc obj) {
243         if (obj == null) {
244             throw new NullPointerException JavaDoc();
245         }
246
247         Entry[] copyOfEntries = entries;
248         int hash = System.identityHashCode(key);
249         int index = (hash & 0x7FFFFFFF) % copyOfEntries.length;
250         for (Entry e = copyOfEntries[index]; e != null; e = e.next) {
251             if (e.key == key) {
252                 Object JavaDoc old = e.value;
253                 e.value = obj;
254                 return old;
255             }
256         }
257
258         modCount++;
259         if (count >= threshold) {
260             rehash();
261             copyOfEntries = entries;
262             index = (hash & 0x7FFFFFFF) % copyOfEntries.length;
263         }
264         Entry e = new Entry(hash, key, obj, copyOfEntries[index]);
265         copyOfEntries[index] = e;
266         count++;
267         return null;
268     }
269
270     /**
271      * Removes the mapping (key and its corresponding value) from this
272      * <tt>TopLinkIdentityHashMap</tt>, if present.
273      *
274      * @param key key whose mapping is to be removed from the map.
275      * @return the previous object for key or <tt>null</tt> if this
276      * <tt>TopLinkIdentityHashMap</tt> did not have one.
277      */

278     public Object JavaDoc remove(Object JavaDoc key) {
279         Entry[] copyOfEntries = entries;
280         int hash = System.identityHashCode(key);
281         int index = (hash & 0x7FFFFFFF) % copyOfEntries.length;
282         for (Entry e = copyOfEntries[index], prev = null; e != null; prev = e, e = e.next) {
283             if (e.key == key) {
284                 if (prev != null) {
285                     prev.next = e.next;
286                 } else {
287                     copyOfEntries[index] = e.next;
288                 }
289                 count--;
290                 return e.value;
291             }
292         }
293         return null;
294     }
295
296     /**
297      * Copies all of the mappings from the given map to this
298      * <tt>TopLinkIdentityHashMap</tt>, replacing any existing mappings.
299      *
300      * @param m mappings to be stored in this <tt>TopLinkIdentityHashMap</tt>.
301      * @throws <tt>NullPointerException</tt> if m is null.
302      */

303     public void putAll(Map m) {
304         if (m == null) {
305             throw new NullPointerException JavaDoc();
306         }
307
308         Iterator i = m.entrySet().iterator();
309         while (i.hasNext()) {
310             Map.Entry me = (Map.Entry)i.next();
311             put(me.getKey(), me.getValue());
312         }
313     }
314
315     /**
316      * Removes all of the mappings from this <tt>TopLinkIdentityHashMap</tt>.
317      */

318     public void clear() {
319         if (count > 0) {
320             modCount++;
321             Entry[] copyOfEntries = entries;
322             for (int i = copyOfEntries.length; --i >= 0;) {
323                 copyOfEntries[i] = null;
324             }
325             count = 0;
326         }
327     }
328
329     /**
330      * Returns a shallow copy of this <tt>TopLinkIdentityHashMap</tt> (the
331      * elements are not cloned).
332      *
333      * @return a shallow copy of this <tt>TopLinkIdentityHashMap</tt>.
334      */

335     public Object JavaDoc clone() {
336         try {
337             Entry[] copyOfEntries = entries;
338             TopLinkIdentityHashMap clone = (TopLinkIdentityHashMap)super.clone();
339             clone.entries = new Entry[copyOfEntries.length];
340             for (int i = copyOfEntries.length; i-- > 0;) {
341                 clone.entries[i] = (copyOfEntries[i] != null) ? (Entry)copyOfEntries[i].clone() : null;
342             }
343             clone.keySet = null;
344             clone.entrySet = null;
345             clone.values = null;
346             clone.modCount = 0;
347             return clone;
348         } catch (CloneNotSupportedException JavaDoc e) {
349             // this shouldn't happen, since we are Cloneable
350
throw new InternalError JavaDoc();
351         }
352     }
353
354     // Views - the following is standard 'boiler-plate' Map stuff
355
private transient Set keySet = null;
356     private transient Set entrySet = null;
357     private transient Collection values = null;
358
359     /**
360      * Returns a set view of the keys contained in this
361      * <tt>TopLinkIdentityHashMap</tt>. The set is backed by the map, so
362      * changes to the map are reflected in the set, and vice versa. The set
363      * supports element removal, which removes the corresponding mapping from
364      * this map, via the <tt>Iterator.remove</tt>, <tt>Set.remove</tt>,
365      * <tt>removeAll</tt>, <tt>retainAll</tt>, and <tt>clear</tt> operations.
366      * It does not support the <tt>add</tt> or <tt>addAll</tt> operations.
367      *
368      * @return a set view of the keys contained in this
369      * <tt>TopLinkIdentityHashMap</tt>.
370      */

371     public Set keySet() {
372         if (keySet == null) {
373             keySet = new AbstractSet() {
374                         public Iterator iterator() {
375                             return getHashIterator(KEYS);
376                         }
377
378                         public int size() {
379                             return count;
380                         }
381
382                         public boolean contains(Object JavaDoc o) {
383                             return containsKey(o);
384                         }
385
386                         public boolean remove(Object JavaDoc o) {
387                             int oldSize = count;
388                             TopLinkIdentityHashMap.this.remove(o);
389                             return count != oldSize;
390                         }
391
392                         public void clear() {
393                             TopLinkIdentityHashMap.this.clear();
394                         }
395                     };
396         }
397         return keySet;
398     }
399
400     /**
401      * Returns a collection view of the values contained in this
402      * <tt>TopLinkIdentityHashMap</tt>. The collection is backed by the map, so
403      * changes to the map are reflected in the collection, and vice versa. The
404      * collection supports element removal, which removes the corresponding
405      * mapping from this map, via the <tt>Iterator.remove</tt>,
406      * <tt>Collection.remove</tt>, <tt>removeAll</tt>, <tt>retainAll</tt>, and
407      * <tt>clear</tt> operations. It does not support the <tt>add</tt> or
408      * <tt>addAll</tt> operations.
409      *
410      * @return a collection view of the values contained in this
411      * <tt>TopLinkIdentityHashMap</tt>.
412      */

413     public Collection values() {
414         if (values == null) {
415             values = new AbstractCollection() {
416                         public Iterator iterator() {
417                             return getHashIterator(VALUES);
418                         }
419
420                         public int size() {
421                             return count;
422                         }
423
424                         public boolean contains(Object JavaDoc o) {
425                             return containsValue(o);
426                         }
427
428                         public void clear() {
429                             TopLinkIdentityHashMap.this.clear();
430                         }
431                     };
432         }
433         return values;
434     }
435
436     /**
437      * Returns a collection view of the mappings contained in this
438      * <tt>TopLinkIdentityHashMap</tt>. Each element in the returned collection
439      * is a <tt>Map.Entry</tt>. The collection is backed by the map, so changes
440      * to the map are reflected in the collection, and vice versa. The
441      * collection supports element removal, which removes the corresponding
442      * mapping from the map, via the <tt>Iterator.remove</tt>,
443      * <tt>Collection.remove</tt>, <tt>removeAll</tt>, <tt>retainAll</tt>, and
444      * <tt>clear</tt> operations. It does not support the <tt>add</tt> or
445      * <tt>addAll</tt> operations.
446      *
447      * @return a collection view of the mappings contained in this
448      * <tt>TopLinkIdentityHashMap</tt>.
449      */

450     public Set entrySet() {
451         if (entrySet == null) {
452             entrySet = new AbstractSet() {
453                         public Iterator iterator() {
454                             return getHashIterator(ENTRIES);
455                         }
456
457                         public boolean contains(Object JavaDoc o) {
458                             if (!(o instanceof Map.Entry)) {
459                                 return false;
460                             }
461
462                             Map.Entry entry = (Map.Entry)o;
463                             Object JavaDoc key = entry.getKey();
464                             Entry[] copyOfEntries = entries;
465                             int hash = System.identityHashCode(key);
466                             int index = (hash & 0x7FFFFFFF) % copyOfEntries.length;
467                             for (Entry e = copyOfEntries[index]; e != null; e = e.next) {
468                                 if ((e.hash == hash) && e.equals(entry)) {
469                                     return true;
470                                 }
471                             }
472                             return false;
473                         }
474
475                         public boolean remove(Object JavaDoc o) {
476                             if (!(o instanceof Map.Entry)) {
477                                 return false;
478                             }
479
480                             Map.Entry entry = (Map.Entry)o;
481                             Object JavaDoc key = entry.getKey();
482                             Entry[] copyOfEntries = entries;
483                             int hash = System.identityHashCode(key);
484                             int index = (hash & 0x7FFFFFFF) % copyOfEntries.length;
485                             for (Entry e = copyOfEntries[index], prev = null; e != null;
486                                      prev = e, e = e.next) {
487                                 if ((e.hash == hash) && e.equals(entry)) {
488                                     modCount++;
489                                     if (prev != null) {
490                                         prev.next = e.next;
491                                     } else {
492                                         copyOfEntries[index] = e.next;
493                                     }
494                                     count--;
495                                     e.value = null;
496                                     return true;
497                                 }
498                             }
499                             return false;
500                         }
501
502                         public int size() {
503                             return count;
504                         }
505
506                         public void clear() {
507                             TopLinkIdentityHashMap.this.clear();
508                         }
509                     };
510         }
511         return entrySet;
512     }
513
514     private Iterator getHashIterator(int type) {
515         if (count == 0) {
516             return emptyHashIterator;
517         } else {
518             return new HashIterator(type);
519         }
520     }
521
522     /**
523      * TopLinkIdentityHashMap entry.
524      */

525     private static class Entry implements Map.Entry {
526         int hash;
527         Object JavaDoc key;
528         Object JavaDoc value;
529         Entry next;
530
531         Entry(int hash, Object JavaDoc key, Object JavaDoc value, Entry next) {
532             this.hash = hash;
533             this.key = key;
534             this.value = value;
535             this.next = next;
536         }
537
538         protected Object JavaDoc clone() {
539             return new Entry(hash, key, value, ((next == null) ? null : (Entry)next.clone()));
540         }
541
542         // Map.Entry Ops
543
public Object JavaDoc getKey() {
544             return key;
545         }
546
547         public Object JavaDoc getValue() {
548             return value;
549         }
550
551         public Object JavaDoc setValue(Object JavaDoc value) {
552             Object JavaDoc oldValue = this.value;
553             this.value = value;
554             return oldValue;
555         }
556
557         public boolean equals(Object JavaDoc o) {
558             if (!(o instanceof Map.Entry)) {
559                 return false;
560             }
561
562             Map.Entry e = (Map.Entry)o;
563             return (key == e.getKey()) && ((value == null) ? (e.getValue() == null) : value.equals(e.getValue()));
564         }
565
566         public int hashCode() {
567             return hash ^ ((value == null) ? 0 : value.hashCode());
568         }
569
570         public String JavaDoc toString() {
571             return key + "=" + value;
572         }
573     }
574
575     // Types of Iterators
576
private static final int KEYS = 0;
577     private static final int VALUES = 1;
578     private static final int ENTRIES = 2;
579     private static EmptyHashIterator emptyHashIterator = new EmptyHashIterator();
580
581     private static class EmptyHashIterator implements Iterator {
582         EmptyHashIterator() {
583         }
584
585         public boolean hasNext() {
586             return false;
587         }
588
589         public Object JavaDoc next() {
590             throw new NoSuchElementException();
591         }
592
593         public void remove() {
594             throw new IllegalStateException JavaDoc();
595         }
596     }
597
598     private class HashIterator implements Iterator {
599         Entry[] entries = TopLinkIdentityHashMap.this.entries;
600         int index = entries.length;
601         Entry entry = null;
602         Entry lastReturned = null;
603         int type;
604
605         /**
606          * The modCount value that the iterator believes that the backing
607          * List should have. If this expectation is violated, the iterator
608          * has detected concurrent modification.
609          */

610         private int expectedModCount = modCount;
611
612         HashIterator(int type) {
613             this.type = type;
614         }
615
616         public boolean hasNext() {
617             Entry e = entry;
618             int i = index;
619             Entry[] copyOfEntries = TopLinkIdentityHashMap.this.entries;
620             while ((e == null) && (i > 0)) {
621                 e = copyOfEntries[--i];
622             }
623             entry = e;
624             index = i;
625             return e != null;
626         }
627
628         public Object JavaDoc next() {
629             if (modCount != expectedModCount) {
630                 throw new ConcurrentModificationException();
631             }
632
633             Entry et = entry;
634             int i = index;
635             Entry[] copyOfEntries = TopLinkIdentityHashMap.this.entries;
636             while ((et == null) && (i > 0)) {
637                 et = copyOfEntries[--i];
638             }
639             entry = et;
640             index = i;
641             if (et != null) {
642                 Entry e = lastReturned = entry;
643                 entry = e.next;
644                 return (type == KEYS) ? e.key : ((type == VALUES) ? e.value : e);
645             }
646             throw new NoSuchElementException();
647         }
648
649         public void remove() {
650             if (lastReturned == null) {
651                 throw new IllegalStateException JavaDoc();
652             }
653             if (modCount != expectedModCount) {
654                 throw new ConcurrentModificationException();
655             }
656
657             Entry[] copyOfEntries = TopLinkIdentityHashMap.this.entries;
658             int index = (lastReturned.hash & 0x7FFFFFFF) % copyOfEntries.length;
659             for (Entry e = copyOfEntries[index], prev = null; e != null; prev = e, e = e.next) {
660                 if (e == lastReturned) {
661                     modCount++;
662                     expectedModCount++;
663                     if (prev == null) {
664                         copyOfEntries[index] = e.next;
665                     } else {
666                         prev.next = e.next;
667                     }
668                     count--;
669                     lastReturned = null;
670                     return;
671                 }
672             }
673             throw new ConcurrentModificationException();
674         }
675     }
676
677     /**
678      * Serialize the state of this <tt>TopLinkIdentityHashMap</tt> to a stream.
679      *
680      * @serialData The <i>capacity</i> of the <tt>TopLinkIdentityHashMap</tt>
681      * (the length of the bucket array) is emitted (int), followed by the
682      * <i>size</i> of the <tt>TopLinkIdentityHashMap</tt>, followed by the
683      * key-value mappings (in no particular order).
684      */

685     private void writeObject(ObjectOutputStream s) throws IOException {
686         // Write out the threshold, loadfactor (and any hidden 'magic' stuff).
687
s.defaultWriteObject();
688
689         // Write out number of buckets
690
s.writeInt(entries.length);
691         // Write out count
692
s.writeInt(count);
693         // Write out contents
694
for (int i = entries.length - 1; i >= 0; i--) {
695             Entry entry = entries[i];
696             while (entry != null) {
697                 s.writeObject(entry.key);
698                 s.writeObject(entry.value);
699                 entry = entry.next;
700             }
701         }
702     }
703
704     /**
705      * Deserialize the <tt>TopLinkIdentityHashMap</tt> from a stream.
706      */

707     private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException JavaDoc {
708         // Read in the threshold, loadfactor (and any hidden 'magic' stuff).
709
s.defaultReadObject();
710
711         // Read in number of buckets and allocate the bucket array;
712
int numBuckets = s.readInt();
713         entries = new Entry[numBuckets];
714         // Read in size (count)
715
int size = s.readInt();
716
717         // Read the mappings and add to the TopLinkIdentityHashMap
718
for (int i = 0; i < size; i++) {
719             Object JavaDoc key = s.readObject();
720             Object JavaDoc value = s.readObject();
721             put(key, value);
722         }
723     }
724 }
725
Popular Tags