Extract any value from hashmap (one for each key)

user2130951

I have a large map with different keys and several values (DepthFeed) associated to each. I would like to get any value (DepthFeed) from that to be able to extract the name of the instrument one for each key.

I have this map

private static Map<Integer, List<DepthFeed>> mapDepthFeed = new HashMap<>();

From that I would like to do something like, however not returning the keyset integer. Instead I want a List<DepthFeed> back (containing one row for each key)

List<DepthFeed> d = mapPriceFeed.values().stream().distinct().collect(Collectors.toList());
Tagir Valeev

Use

List<DepthFeed> result = mapDepthFeed.values().stream()
            .filter(list -> !list.isEmpty())
            .map(list -> list.get(0))
            .collect(Collectors.toList());

This way you will get the first element from each non-empty list stored in map values.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Extract value from NSObject key/value pair

分類Dev

select a record from each group if it has given value in column otherwise any one record

分類Dev

Extract value for key from json c#

分類Dev

shell: Extract key value from a string with known key

分類Dev

Ruby - Extract value of a particular key from array of hashes

分類Dev

How to extract values from key value map, spark dataframe

分類Dev

Get the value for a specific key from any type in terraform

分類Dev

How to extract list from list of lists when any one element match with another list's element?

分類Dev

Accessing a HashMap value with a custom Pair Object as a key

分類Dev

For HashMap, should I override hashCode for key or value?

分類Dev

Is there any way to avoid the top rows with NULL values that has one column value (One of the table Business Key) in Cognos report prompt values

分類Dev

How to extract all drop down values from a data validated cell in excel to single cells for each value?

分類Dev

Talend Extract Json String As Key value Array

分類Dev

Using R, how does one extract multiple URLs/pattern matches from a string in a dataset, and then place each URL in its own adjacent column?

分類Dev

Java HashMap : How to add multiple values to one key?

分類Dev

Extract Value from nested options

分類Dev

Extract Property value from NodeList

分類Dev

Extract Value from Column in SQL

分類Dev

Extract substrings from a text file on each line?

分類Dev

Query for ANY value in complex key (AKA wildcard)

分類Dev

How do I get the full value(including any additional tags) from .text of an XML key / Value using Javascript

分類Dev

How to extract all the Id's value from the Json given below using Regular expression extractor or any other Extractor(Xpath, Beanshell etc)

分類Dev

Is there any way to get a macro or module to change the copy destination cell from one cell to another cell in the next row with each run?

分類Dev

Get an Object's Property from HashMap Value

分類Dev

How to use HashMap when Json file has same key value

分類Dev

Split a sentence into two words and store as key, value in HashMap

分類Dev

HashMap in JSF not showing the value if the key is a non standard Object

分類Dev

HashMapのKey-Valueの保存と取得

分類Dev

dictionary of key and list - remove key if any value in list is none

Related 関連記事

  1. 1

    Extract value from NSObject key/value pair

  2. 2

    select a record from each group if it has given value in column otherwise any one record

  3. 3

    Extract value for key from json c#

  4. 4

    shell: Extract key value from a string with known key

  5. 5

    Ruby - Extract value of a particular key from array of hashes

  6. 6

    How to extract values from key value map, spark dataframe

  7. 7

    Get the value for a specific key from any type in terraform

  8. 8

    How to extract list from list of lists when any one element match with another list's element?

  9. 9

    Accessing a HashMap value with a custom Pair Object as a key

  10. 10

    For HashMap, should I override hashCode for key or value?

  11. 11

    Is there any way to avoid the top rows with NULL values that has one column value (One of the table Business Key) in Cognos report prompt values

  12. 12

    How to extract all drop down values from a data validated cell in excel to single cells for each value?

  13. 13

    Talend Extract Json String As Key value Array

  14. 14

    Using R, how does one extract multiple URLs/pattern matches from a string in a dataset, and then place each URL in its own adjacent column?

  15. 15

    Java HashMap : How to add multiple values to one key?

  16. 16

    Extract Value from nested options

  17. 17

    Extract Property value from NodeList

  18. 18

    Extract Value from Column in SQL

  19. 19

    Extract substrings from a text file on each line?

  20. 20

    Query for ANY value in complex key (AKA wildcard)

  21. 21

    How do I get the full value(including any additional tags) from .text of an XML key / Value using Javascript

  22. 22

    How to extract all the Id's value from the Json given below using Regular expression extractor or any other Extractor(Xpath, Beanshell etc)

  23. 23

    Is there any way to get a macro or module to change the copy destination cell from one cell to another cell in the next row with each run?

  24. 24

    Get an Object's Property from HashMap Value

  25. 25

    How to use HashMap when Json file has same key value

  26. 26

    Split a sentence into two words and store as key, value in HashMap

  27. 27

    HashMap in JSF not showing the value if the key is a non standard Object

  28. 28

    HashMapのKey-Valueの保存と取得

  29. 29

    dictionary of key and list - remove key if any value in list is none

ホットタグ

アーカイブ