馃摑 Overall Description
A MapSetMultiMap<K, V> can be backed by different user-defined sets to offer functionality similar to but cleaner than a Map<K, Set<V>>, which is quite nice.
However, the Set<V> get(K key) method of the class MapSetMultiMap will return a set of type UnmodifiableSet<V>, instead of using the set generated by the setFactory.
|
public Set<V> get(@Nonnull K key) { |
|
Objects.requireNonNull(key, NULL_KEY); |
|
Set<V> values = map.get(key); |
|
return values == null ? Set.of() : |
|
Collections.unmodifiableSet(values); |
|
} |
For cases when setFactory returns IndexerBitSets and operations like addAll are performed, this implementation will cause severe performance degradation as operations like addAll are slow when the type of the two sets are different.
|
public boolean addAll(@Nonnull Collection<? extends E> c) { |
|
if (c instanceof GenericBitSet s) { |
|
checkContext(s); |
|
return bitSet.or(s.bitSet); |
|
} else { |
|
return super.addAll(c); |
|
} |
|
} |
馃幆 Expected Behavior
return a set of the same type of the sets generated by setFactory
馃悰 Current Behavior
Collections.unmodifiableSet() is used
馃攧 Reproducible Example
No response
鈿欙笍 Tai-e Arguments
馃攳 Click here to see Tai-e Options
{{The content of 'output/options.yml' file}}
馃攳 Click here to see Tai-e Analysis Plan
{{The content of 'output/tai-e-plan.yml' file}}
馃摐 Tai-e Log
馃攳 Click here to see Tai-e Log
{{The content of 'output/tai-e.log' file}}
鈩癸笍 Additional Information
No response
馃摑 Overall Description
A
MapSetMultiMap<K, V>can be backed by different user-defined sets to offer functionality similar to but cleaner than aMap<K, Set<V>>, which is quite nice.However, the
Set<V> get(K key)method of the classMapSetMultiMapwill return a set of typeUnmodifiableSet<V>, instead of using the set generated by thesetFactory.Tai-e/src/main/java/pascal/taie/util/collection/MapSetMultiMap.java
Lines 76 to 81 in e3eadc9
For cases when
setFactoryreturnsIndexerBitSets and operations likeaddAllare performed, this implementation will cause severe performance degradation as operations likeaddAllare slow when the type of the two sets are different.Tai-e/src/main/java/pascal/taie/util/collection/GenericBitSet.java
Lines 100 to 107 in 89a4ea0
馃幆 Expected Behavior
return a set of the same type of the sets generated by
setFactory馃悰 Current Behavior
Collections.unmodifiableSet()is used馃攧 Reproducible Example
No response
鈿欙笍 Tai-e Arguments
馃攳 Click here to see Tai-e Options
{{The content of 'output/options.yml' file}}馃攳 Click here to see Tai-e Analysis Plan
{{The content of 'output/tai-e-plan.yml' file}}馃摐 Tai-e Log
馃攳 Click here to see Tai-e Log
鈩癸笍 Additional Information
No response