Created
August 27, 2011 10:59
-
-
Save abyx/1175248 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
// Why write this.. | |
public static <T, V> Map<T, List<V>> defaultdict_list() { | |
return new MapMaker().makeComputingMap(new Function<T, List<V>>() { | |
@Override public List<V> apply(T unusedCrap) { | |
return Lists.newArrayList(); | |
} | |
}); | |
} | |
# When you just want this (Python) | |
defaultdict(list) | |
# Or this (Ruby) | |
Hash.new {|h,k| h[k] = []} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment