[jboss-cvs] JBossCache/src/org/jboss/cache/util ...
Manik Surtani
manik at jboss.org
Mon Jun 18 18:41:57 EDT 2007
User: msurtani
Date: 07/06/18 18:41:57
Modified: src/org/jboss/cache/util MapCopy.java
Log:
better thread safety
Revision Changes Path
1.10 +8 -8 JBossCache/src/org/jboss/cache/util/MapCopy.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: MapCopy.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/util/MapCopy.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- MapCopy.java 12 Mar 2007 18:13:46 -0000 1.9
+++ MapCopy.java 18 Jun 2007 22:41:57 -0000 1.10
@@ -4,8 +4,10 @@
import java.io.Serializable;
import java.util.AbstractMap;
import java.util.AbstractSet;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -23,7 +25,7 @@
private static final long serialVersionUID = -958813082188242956L;
- private Map.Entry<K, V> data[];
+ private List<Entry<K, V>> data = new ArrayList<Entry<K, V>>();
private transient Set<Map.Entry<K, V>> entrySet;
@@ -34,13 +36,12 @@
*/
public MapCopy(Map<K, V> m)
{
- data = new Map.Entry[m.size()];
int i = 0;
for (Map.Entry<K, V> me : m.entrySet())
{
if (me == null)
throw new NullPointerException();
- data[i++] = new SimpleEntry<K, V>(me);
+ data.add(new SimpleEntry<K, V>(me));
}
init();
}
@@ -56,7 +57,7 @@
{
public int size()
{
- return data.length;
+ return data.size();
}
public Iterator<Map.Entry<K, V>> iterator()
@@ -72,12 +73,12 @@
public boolean hasNext()
{
- return index < data.length;
+ return index < data.size();
}
public Entry<K, V> next()
{
- return data[index++];
+ return data.get(index++);
}
public void remove()
@@ -95,7 +96,7 @@
@Override
public int size()
{
- return data.length;
+ return data.size();
}
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException
@@ -103,5 +104,4 @@
in.defaultReadObject();
init();
}
-
}
More information about the jboss-cvs-commits
mailing list