Created
June 30, 2010 11:04
-
-
Save diroussel/458523 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* Returns an Iterable of all the values in all the submaps of the parent map. | |
*/ | |
<K1, K2, T> Iterable<T> innerValues(Map<K1, Map<K2, T>> map) { | |
return Iterables.concat( | |
Iterables.transform(map.values(), | |
new Function<Map<K2, T>, Iterable<T>>() { | |
@Override | |
public Iterable<T> apply(Map<K2, T> innerMap) { | |
return innerMap.values(); | |
} | |
} | |
) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist was written before java had streams. If I was doing this now, it would be like this: ...