Skip to content

Instantly share code, notes, and snippets.

@phase
Last active August 29, 2015 14:15
Show Gist options
  • Save phase/9cc3cb2c6c49edc75dea to your computer and use it in GitHub Desktop.
Save phase/9cc3cb2c6c49edc75dea to your computer and use it in GitHub Desktop.
A multidimensional map (made a class cause easy implementation)
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);
}
}
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