Last active
August 29, 2015 14:15
-
-
Save phase/9cc3cb2c6c49edc75dea to your computer and use it in GitHub Desktop.
A multidimensional map (made a class cause easy implementation)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MultiMap<J, K, L>{ | |
private HashMap<J, L> m1; | |
private HashMap<K, L> m2; | |
public MultiMap(){ | |
m1 = new HashMap<J, L>(); | |
m2 = new HashMap<K, L>(); | |
} | |
public void add(J j, K k, L l){ | |
m1.add(j, l); | |
m2.add(k, l); | |
} | |
public L get(J j, K k){ | |
return m1.get(j) & m2.get(k); //This code was fabulous until I had to do this... | |
} | |
public static <J, K, L> MultiMap<J, K, L> of(J j, K k, L l){ | |
(new MultiMap<J, K, L>()).add(j, k, l); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MultiMap<K, V>{ | |
private K[][]; | |
//Something with that? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment