DaveAKing / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

AtomicLongMap.incrementAll(Iterable<K>) #1676

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Of course, this would increment the value for each key passed in, as many times 
as the key was passed in, and of course there would be a fast path if the 
iterable is a multiset.

I don't have a list of motivating real-world use cases to provide yet; I just 
noticed that the recurring "how do I convert a multiset into a map of counts?" 
question could potentially be addressed by this.

Original issue reported on code.google.com by kevinb@google.com on 20 Feb 2014 at 4:34

GoogleCodeExporter commented 9 years ago
Today:

    Map<String, Integer> result = new HashMap<>();
    for(String element: multiset.elementSet()) {
        result.put(element, multiset.count(element));
    }
    // return ImmutableMap.copyOf(result); ?

Tomorrow?

    AtomicLongMap<String> result = AtomicLongMap.create();
    result.incrementAll(multiset);
    // return ImmutableMap.copyOf(result.asMap()); ?

Original comment by kevinb@google.com on 20 Feb 2014 at 4:36

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:09

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:17

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:07