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

Method put

src/main/java/pascal/taie/util/collection/IndexMap.java:107–123  ·  view source on GitHub ↗
(K key, V value)

Source from the content-addressed store, hash-verified

105 }
106
107 @Override
108 public V put(K key, V value) {
109 Objects.requireNonNull(value, NULL_VALUE_MSG);
110 int index = indexer.getIndex(key);
111 if (index >= 0) {
112 ensureCapacity(index);
113 V oldV = values[index];
114 values[index] = value;
115 if (oldV == null) {
116 ++size;
117 }
118 return oldV;
119 } else {
120 throw new IllegalArgumentException("index of " + key +
121 " is negative: " + index);
122 }
123 }
124
125 private void ensureCapacity(int index) {
126 int oldCapacity = values.length;

Callers 2

makeMapMethod · 0.95
testMapExpansionMethod · 0.95

Calls 2

ensureCapacityMethod · 0.95
getIndexMethod · 0.65

Tested by 2

makeMapMethod · 0.76
testMapExpansionMethod · 0.76