Index: trunk/src/org/openstreetmap/josm/command/PurgeCommand.java
===================================================================
--- trunk/src/org/openstreetmap/josm/command/PurgeCommand.java	(revision 5673)
+++ trunk/src/org/openstreetmap/josm/command/PurgeCommand.java	(revision 5674)
@@ -16,5 +16,4 @@
 
 import org.openstreetmap.josm.data.osm.DataSet;
-import org.openstreetmap.josm.data.osm.Hash;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.NodeData;
@@ -65,22 +64,6 @@
 
     protected void saveIncomplete(Collection<OsmPrimitive> makeIncomplete) {
-        makeIncompleteData = new Storage<PrimitiveData>(new Hash<PrimitiveData,PrimitiveData>() {
-            public int getHashCode(PrimitiveData k) {
-                return (int) k.getUniqueId();
-            }
-
-            public boolean equals(PrimitiveData k, PrimitiveData t) {
-                return k.getUniqueId() == t.getUniqueId() && k.getType() == t.getType();
-            }
-        });
-        makeIncompleteData_byPrimId = makeIncompleteData.foreignKey(new Hash<PrimitiveId, PrimitiveData>() {
-            public int getHashCode(PrimitiveId k) {
-                return (int) k.getUniqueId();
-            }
-
-            public boolean equals(PrimitiveId k, PrimitiveData t) {
-                return k.getUniqueId() == t.getUniqueId() && k.getType() == t.getType();
-            }
-        });
+        makeIncompleteData = new Storage<PrimitiveData>(new Storage.PrimitiveIdHash());
+        makeIncompleteData_byPrimId = makeIncompleteData.foreignKey(new Storage.PrimitiveIdHash());
 
         for (OsmPrimitive osm : makeIncomplete) {
@@ -191,62 +174,62 @@
             }
 
-        /**
-         * Rest are relations. Do topological sorting on a DAG where each
-         * arrow points from child to parent. (Because it is faster to
-         * loop over getReferrers() than getMembers().)
-         */
-        Set<Relation> inR = (Set) in;
-        Set<Relation> childlessR = new HashSet<Relation>();
-        List<Relation> outR = new ArrayList<Relation>(inR.size());
-
-        HashMap<Relation, Integer> numChilds = new HashMap<Relation, Integer>();
-
-        // calculate initial number of childs
-        for (Relation r : inR) {
-            numChilds.put(r, 0);
-        }
-        for (Relation r : inR) {
-            for (OsmPrimitive parent : r.getReferrers()) {
-                if (!(parent instanceof Relation))
-                    throw new AssertionError();
-                Integer i = numChilds.get(parent);
-                if (i != null) {
-                    numChilds.put((Relation)parent, i+1);
-                }
-            }
-        }
-        for (Relation r : inR) {
-            if (numChilds.get(r).equals(0)) {
-                childlessR.add(r);
-            }
-        }
-
-        while (!childlessR.isEmpty()) {
-            // Identify one childless Relation and
-            // let it virtually die. This makes other
-            // relations childless.
-            Iterator<Relation> it  = childlessR.iterator();
-            Relation next = it.next();
-            it.remove();
-            outR.add(next);
-
-            for (OsmPrimitive parentPrim : next.getReferrers()) {
-                Relation parent = (Relation) parentPrim;
-                Integer i = numChilds.get(parent);
-                if (i != null) {
-                    numChilds.put(parent, i-1);
-                    if (i-1 == 0) {
-                        childlessR.add(parent);
-                    }
-                }
-            }
-        }
-
-        if (outR.size() != inR.size())
-            throw new AssertionError("topo sort algorithm failed");
-
-        out.addAll(outR);
-
-        return out;
+            /**
+             * Rest are relations. Do topological sorting on a DAG where each
+             * arrow points from child to parent. (Because it is faster to
+             * loop over getReferrers() than getMembers().)
+             */
+            Set<Relation> inR = (Set) in;
+            Set<Relation> childlessR = new HashSet<Relation>();
+            List<Relation> outR = new ArrayList<Relation>(inR.size());
+
+            HashMap<Relation, Integer> numChilds = new HashMap<Relation, Integer>();
+
+            // calculate initial number of childs
+            for (Relation r : inR) {
+                numChilds.put(r, 0);
+            }
+            for (Relation r : inR) {
+                for (OsmPrimitive parent : r.getReferrers()) {
+                    if (!(parent instanceof Relation))
+                        throw new AssertionError();
+                    Integer i = numChilds.get(parent);
+                    if (i != null) {
+                        numChilds.put((Relation)parent, i+1);
+                    }
+                }
+            }
+            for (Relation r : inR) {
+                if (numChilds.get(r).equals(0)) {
+                    childlessR.add(r);
+                }
+            }
+
+            while (!childlessR.isEmpty()) {
+                // Identify one childless Relation and
+                // let it virtually die. This makes other
+                // relations childless.
+                Iterator<Relation> it  = childlessR.iterator();
+                Relation next = it.next();
+                it.remove();
+                outR.add(next);
+
+                for (OsmPrimitive parentPrim : next.getReferrers()) {
+                    Relation parent = (Relation) parentPrim;
+                    Integer i = numChilds.get(parent);
+                    if (i != null) {
+                        numChilds.put(parent, i-1);
+                        if (i-1 == 0) {
+                            childlessR.add(parent);
+                        }
+                    }
+                }
+            }
+
+            if (outR.size() != inR.size())
+                throw new AssertionError("topo sort algorithm failed");
+
+            out.addAll(outR);
+
+            return out;
     }
 
Index: trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/DataSet.java	(revision 5673)
+++ trunk/src/org/openstreetmap/josm/data/osm/DataSet.java	(revision 5674)
@@ -100,18 +100,6 @@
     private static final int MAX_EVENTS = 1000;
 
-    private static class IdHash implements Hash<PrimitiveId,OsmPrimitive> {
-
-        public int getHashCode(PrimitiveId k) {
-            return (int)k.getUniqueId() ^ k.getType().hashCode();
-        }
-
-        public boolean equals(PrimitiveId key, OsmPrimitive value) {
-            if (key == null || value == null) return false;
-            return key.getUniqueId() == value.getUniqueId() && key.getType() == value.getType();
-        }
-    }
-
-    private Storage<OsmPrimitive> allPrimitives = new Storage<OsmPrimitive>(new IdHash(), true);
-    private Map<PrimitiveId, OsmPrimitive> primitivesMap = allPrimitives.foreignKey(new IdHash());
+    private Storage<OsmPrimitive> allPrimitives = new Storage<OsmPrimitive>(new Storage.PrimitiveIdHash(), true);
+    private Map<PrimitiveId, OsmPrimitive> primitivesMap = allPrimitives.foreignKey(new Storage.PrimitiveIdHash());
     private CopyOnWriteArrayList<DataSetListener> listeners = new CopyOnWriteArrayList<DataSetListener>();
 
@@ -126,5 +114,5 @@
 
     private int highlightUpdateCount;
-    
+
     private boolean uploadDiscouraged = false;
 
@@ -486,5 +474,5 @@
         return new SubclassFilteredCollection<OsmPrimitive, OsmPrimitive>(getAllSelected(), OsmPrimitive.nonDeletedPredicate);
     }
-    
+
     /**
      * Replies an unmodifiable collection of primitives currently selected
@@ -1177,7 +1165,7 @@
      */
     public void mergeFrom(DataSet from) {
-    	mergeFrom(from, null);
-    }
-    
+        mergeFrom(from, null);
+    }
+
     /**
      * Moves all primitives and datasources from DataSet "from" to this DataSet
Index: trunk/src/org/openstreetmap/josm/data/osm/Storage.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/Storage.java	(revision 5673)
+++ trunk/src/org/openstreetmap/josm/data/osm/Storage.java	(revision 5674)
@@ -87,4 +87,17 @@
  */
 public class Storage<T> extends AbstractSet<T> {
+
+    public static class PrimitiveIdHash implements Hash<PrimitiveId, PrimitiveId> {
+
+        public int getHashCode(PrimitiveId k) {
+            return (int)k.getUniqueId() ^ k.getType().hashCode();
+        }
+
+        public boolean equals(PrimitiveId key, PrimitiveId value) {
+            if (key == null || value == null) return false;
+            return key.getUniqueId() == value.getUniqueId() && key.getType() == value.getType();
+        }
+    }
+
     private final Hash<? super T,? super T> hash;
     private T[] data;
