MCPcopy Create free account
hub / github.com/LFYSec/MScan / Maps

Class Maps

src/main/java/pascal/taie/util/collection/Maps.java:35–164  ·  view source on GitHub ↗

Static utility methods for various maps, including Map, MultiMap, and TwoKeyMap.

Source from the content-addressed store, hash-verified

33 * {@link MultiMap}, and {@link TwoKeyMap}.
34 */
35public final class Maps {
36
37 private Maps() {
38 }
39
40 public static <K, V> Map<K, V> ofLinkedHashMap(K k1, V v1, K k2, V v2) {
41 Map<K, V> map = new LinkedHashMap<>(2);
42 map.put(k1, v1);
43 map.put(k2, v2);
44 return Collections.unmodifiableMap(map);
45 }
46
47 public static <K, V> Map<K, V> newMap() {
48 return new HashMap<>();
49 }
50
51 public static <K, V> Map<K, V> newMap(int initialCapacity) {
52 if (initialCapacity <= ArrayMap.DEFAULT_CAPACITY) {
53 return newSmallMap();
54 } else {
55 return newMap();
56 }
57 }
58
59 public static <K, V> Map<K, V> newLinkedHashMap() {
60 return new LinkedHashMap<>();
61 }
62
63 public static <K extends Comparable<K>, V> Map<K, V> newOrderedMap() {
64 return new TreeMap<>();
65 }
66
67 public static <K, V> Map<K, V> newOrderedMap(Comparator<? super K> comparator) {
68 return new TreeMap<>(comparator);
69 }
70
71 public static <K, V> Map<K, V> newSmallMap() {
72 return new ArrayMap<>();
73 }
74
75 public static <K, V> Map<K, V> newHybridMap() {
76 return new HybridHashMap<>();
77 }
78
79 public static <K, V> Map<K, V> newHybridMap(Map<K, V> map) {
80 return new HybridHashMap<>(map);
81 }
82
83 public static <K, V> ConcurrentMap<K, V> newConcurrentMap() {
84 return new ConcurrentHashMap<>();
85 }
86
87 public static <K, V> ConcurrentMap<K, V> newConcurrentMap(int initialCapacity) {
88 return new ConcurrentHashMap<>(initialCapacity);
89 }
90
91 public static <K, V> MultiMap<K, V> newMultiMap(Map<K, Set<V>> map,
92 SSupplier<Set<V>> setFactory) {

Callers

nothing calls this directly

Calls 4

unmodifiableMultiMapMethod · 0.95
newMultiMapMethod · 0.95
newTwoKeyMultiMapMethod · 0.95

Tested by

no test coverage detected