I have a hash table containing N hast tables:
Map<Integer,Map<String,Double>
I need to create a list containing all the keys of the inner maps:
----------------
| | a 2 |
| 100 | b 1 |
| | c 2 |
----------------
| | a 2 |
| 101 | d 2 |
----------------
| | a 2 |
| 102 | b 1 |
| | e 2 |
----------------
list = {a,b,c,d,e}
Here my current code:
Set<String> keys= new HashSet<>();
map1.entrySet().forEach(e -> {
keys.addAll(e.getValue().keySet());
});
map1 contains thousands of entries.
Is this the optimal approach? Anyone know a faster way?