Tables.computeIfAbsent
See original GitHub issueIssue #902 requests Multitable
, which we have been hesitant to add because of complexity.
When the JDK was hesitant to add even Multimap
and Multiset
, they added Map.computeIfAbsent
, which serves many of the same use cases noticeably less well but with a significantly smaller API footprint. Perhaps we could do the same here? We could wait for Java 8 to add a true default method, or we could provide it as a static method.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:8
- Comments:11 (10 by maintainers)
Top Results From Across the Web
Hashtable computeIfAbsent() method in Java with Examples
The computeIfAbsent(Key, Function) method of Hashtable class which allows you to compute value of a mapping for specified key if key is not ......
Read more >The Map.computeIfAbsent() Method - Baeldung
In this tutorial, we'll discuss the new default method, computeIfAbsent, of the Map interface introduced in Java 8.
Read more >How do I use the new computeIfAbsent function?
As you can see, the method computeIfAbsent will use the provided lambda expression to calculate the Fibonacci number when the number is not ......
Read more >Java HashMap.computeIfAbsent() - Syntax & Examples
computeIfAbsent (). HashMap.computeIfAbsent() computes the value for given key, using the given mapping function and puts this entry into this HashMap.
Read more >Hashtable (Java Platform SE 8 ) - Oracle Help Center
This class implements a hash table, which maps keys to values. Any non- null object can be used as a ... computeIfAbsent(key, k...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Very rough searches: ~6% of
Table
usages inside Google are either aTable<..., ..., List>
orTable<..., ..., Set>
. Compare to ~8% ofMap
usages withList
/Set
values (despite the existence ofMultimap
, which is itself ~13% as popular asMap
).(And of course, users may be using different workarounds –
Map<R, Map<C, List<V>>
,Multimap<R, Pair<C, List<V>>
, or whatever.)If anyone wants to dig deeper, I suggest a search along the lines of:
\bTable<[^(=]*,\s*(List|Set)<.*>> case:yes lang:java
Any chance of this becoming a thing? 😺