MCPcopy Index your code
hub / github.com/apache/groovy / put

Method put

src/main/java/org/codehaus/groovy/util/ListHashMap.java:139–170  ·  view source on GitHub ↗

{@inheritDoc}

(K key, V value)

Source from the content-addressed store, hash-verified

137
138 /** {@inheritDoc} */
139 @Override
140 public V put(K key, V value) {
141 if (key != null) {
142 if (value == null) {
143 return remove(key);
144 }
145 if (innerMap != null) {
146 V old = innerMap.put(key, value);
147 if (old == null) size += 1;
148 return old;
149 }
150 for (int i = 0; i < size; i += 1) {
151 if (key.equals(keys[i])) {
152 V old = values[i];
153 values[i] = value;
154 return old;
155 }
156 }
157 if (size < keys.length) {
158 int i = (size ++);
159 values[i] = value;
160 keys[i] = key;
161 } else { // evolve
162 Map<K,V> map = toMap();
163 map.put(key, value);
164 innerMap = map;
165 clearArrays();
166 size += 1;
167 }
168 }
169 return null;
170 }
171
172 /** {@inheritDoc} */
173 @Override

Callers 3

depthFirstMethod · 0.95
breadthFirstMethod · 0.95
putAllMethod · 0.95

Calls 5

removeMethod · 0.95
toMapMethod · 0.95
clearArraysMethod · 0.95
putMethod · 0.65
equalsMethod · 0.65

Tested by

no test coverage detected