java - Extract any value from hashmap (one for each key) -


i have large map different keys , several values (depthfeed) associated each. value (depthfeed) able extract name of instrument 1 each key.

i have map

private static map<integer, list<depthfeed>> mapdepthfeed = new hashmap<>(); 

from like, not returning keyset integer. instead want list<depthfeed> (containing 1 row each key)

list<depthfeed> d = mappricefeed.values().stream().distinct().collect(collectors.tolist()); 

use

list<depthfeed> result = mapdepthfeed.values().stream()             .filter(list -> !list.isempty())             .map(list -> list.get(0))             .collect(collectors.tolist()); 

this way first element each non-empty list stored in map values.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -