]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/internal/HashMultiMap.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.debug.ui / src / org / simantics / debug / ui / internal / HashMultiMap.java
diff --git a/bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/internal/HashMultiMap.java b/bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/internal/HashMultiMap.java
new file mode 100644 (file)
index 0000000..b37a003
--- /dev/null
@@ -0,0 +1,45 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.debug.ui.internal;\r
+\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+\r
+public class HashMultiMap<D,R> extends HashMap<D,List<R>> {\r
+\r
+    private static final long serialVersionUID = 8928508639019379832L;\r
+\r
+    public void add(D a, R b) {\r
+        List<R> elements = get(a);\r
+        if(elements == null) {\r
+            elements = new ArrayList<R>(1);\r
+            put(a, elements);\r
+        }\r
+        elements.add(b);\r
+    }\r
+    \r
+//    public boolean remove(D a, R b) {\r
+//        List<R> elements = get(a);\r
+//        if(elements == null) \r
+//            return false;\r
+//        if(elements.remove(b)) {\r
+//            // This would makes in some applications\r
+//            //if(elements.isEmpty())\r
+//            //  remove(a);\r
+//            return true;\r
+//        }\r
+//        else\r
+//            return false;\r
+//    }\r
+    \r
+}\r