Last active
December 17, 2015 13:59
-
-
Save alalwww/5621491 to your computer and use it in GitHub Desktop.
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 Main { | |
public static main(String... args) { | |
Map<Integer, Map<Position, Box>> backingMap = Maps.newHashMap(); | |
Supplier<Map<Position, Box>> factory = newMapFactory(); | |
Table<Integer, Position, Box> table = Tables.newCustomTable(backingMap, factory); | |
Integer rowKey = 0; | |
Position columnKey = getPosition(); | |
Box value = new Box(); | |
// put | |
table.put(rowKey, columnKey, value); | |
// get | |
Box box = table.get(rowKey, columnKey); | |
} | |
static <C, V> Supplier<Map<C, V>> newMapFactory() { | |
return new MapFactory<C, V>(); | |
} | |
static final class MapFactory<C, V> implements Supplier<Map<C, V>> { | |
public Map<C, V> get() { | |
return Maps.newHashMap(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment