garydgregory commented on code in PR #665:
URL:
https://github.com/apache/commons-collections/pull/665#discussion_r2616528029
##########
src/main/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMap.java:
##########
@@ -118,6 +119,13 @@ protected ArrayList<V> createCollection() {
return new ArrayList<>(initialListCapacity);
}
+ @Override
+ public ArrayListValuedHashMap<V, K> inverse() {
+ final ArrayListValuedHashMap<V, K> result = new
ArrayListValuedHashMap<>();
+ MultiMapUtils.inverseInto(this, result);
+ return result;
Review Comment:
No need to be so verbose here and for all implementations IMO:
```suggestion
return MultiMapUtils.inverseInto(this, new
ArrayListValuedHashMap<>());
```
##########
src/main/java/org/apache/commons/collections4/MultiValuedMap.java:
##########
@@ -140,6 +140,16 @@ public interface MultiValuedMap<K, V> {
*/
Collection<V> get(K key);
+ /**
+ * Returns the inverse of this MultiValuedMap. The inverse has a
value-to-key mapping
+ * for each key-to-value mapping in the original.
+ *
+ * @return the inverse MultiValuedMap
+ */
+ default MultiValuedMap<V, K> inverse() {
Review Comment:
Java 21 has `java.util.List.reversed()`, so how about `inverted()` to match
the same naming pattern?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]