question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tables.computeIfAbsent

See original GitHub issue

Issue #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:open
  • Created 8 years ago
  • Reactions:8
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
cpovirkcommented, Sep 27, 2016

Very rough searches: ~6% of Table usages inside Google are either a Table<..., ..., List> or Table<..., ..., Set>. Compare to ~8% of Map usages with List/Set values (despite the existence of Multimap, which is itself ~13% as popular as Map).

(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

0reactions
kashikecommented, Apr 20, 2018

Any chance of this becoming a thing? 😺

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found