Lines Matching defs:map

28  * @run main/othervm -Djdk.map.althashing.threshold=0 Collisions -shortrun
39 * Number of elements per map.
158 // for each map type.
159 for (Map<Object, Object> map : maps) {
163 testMap(map, desc, keys);
165 unexpected("Failed for " + map.getClass().getName() + " with " + desc, all);
171 private static <T> void testMap(Map<T, T> map, String keys_desc, T[] keys) {
172 System.out.println(map.getClass() + " : " + keys_desc);
174 testInsertion(map, keys_desc, keys);
177 testIntegerIteration((Map<HashableInteger, HashableInteger>) map, (HashableInteger[]) keys);
179 testStringIteration((Map<String, String>) map, (String[]) keys);
182 testContainsKey(map, keys_desc, keys);
184 testRemove(map, keys_desc, keys);
186 map.clear();
187 testInsertion(map, keys_desc, keys);
188 testKeysIteratorRemove(map, keys_desc, keys);
190 map.clear();
191 testInsertion(map, keys_desc, keys);
192 testValuesIteratorRemove(map, keys_desc, keys);
194 map.clear();
195 testInsertion(map, keys_desc, keys);
196 testEntriesIteratorRemove(map, keys_desc, keys);
198 check(map.isEmpty());
201 private static <T> void testInsertion(Map<T, T> map, String keys_desc, T[] keys) {
202 check("map empty", (map.size() == 0) && map.isEmpty());
205 check(String.format("insertion: map expected size m%d != i%d", map.size(), i),
206 map.size() == i);
207 check(String.format("insertion: put(%s[%d])", keys_desc, i), null == map.put(keys[i], keys[i]));
208 check(String.format("insertion: containsKey(%s[%d])", keys_desc, i), map.containsKey(keys[i]));
209 check(String.format("insertion: containsValue(%s[%d])", keys_desc, i), map.containsValue(keys[i]));
212 check(String.format("map expected size m%d != k%d", map.size(), keys.length),
213 map.size() == keys.length);
216 private static void testIntegerIteration(Map<HashableInteger, HashableInteger> map, HashableInteger[] keys) {
217 check(String.format("map expected size m%d != k%d", map.size(), keys.length),
218 map.size() == keys.length);
221 for (Map.Entry<HashableInteger, HashableInteger> each : map.entrySet()) {
229 for (HashableInteger each : map.keySet()) {
238 for (HashableInteger each : map.values()) {
242 check(String.format("Iteration: value count matches size m%d != c%d", map.size(), count),
243 map.size() == count);
246 private static void testStringIteration(Map<String, String> map, String[] keys) {
247 check(String.format("map expected size m%d != k%d", map.size(), keys.length),
248 map.size() == keys.length);
251 for (Map.Entry<String, String> each : map.entrySet()) {
262 for (String each : map.keySet()) {
273 for (String each : map.values()) {
277 check(String.format("value count matches size m%d != k%d", map.size(), keys.length),
278 map.size() == keys.length);
281 private static <T> void testContainsKey(Map<T, T> map, String keys_desc, T[] keys) {
284 check("containsKey: " + keys_desc + "[" + i + "]" + each, map.containsKey(each));
288 private static <T> void testRemove(Map<T, T> map, String keys_desc, T[] keys) {
289 check(String.format("remove: map expected size m%d != k%d", map.size(), keys.length),
290 map.size() == keys.length);
294 check("remove: " + keys_desc + "[" + i + "]" + each, null != map.remove(each));
297 check(String.format("remove: map empty. size=%d", map.size()),
298 (map.size() == 0) && map.isEmpty());
301 private static <T> void testKeysIteratorRemove(Map<T, T> map, String keys_desc, T[] keys) {
302 check(String.format("remove: map expected size m%d != k%d", map.size(), keys.length),
303 map.size() == keys.length);
305 Iterator<T> each = map.keySet().iterator();
309 check("not removed: " + each, !map.containsKey(t) );
312 check(String.format("remove: map empty. size=%d", map.size()),
313 (map.size() == 0) && map.isEmpty());
316 private static <T> void testValuesIteratorRemove(Map<T, T> map, String keys_desc, T[] keys) {
317 check(String.format("remove: map expected size m%d != k%d", map.size(), keys.length),
318 map.size() == keys.length);
320 Iterator<T> each = map.values().iterator();
324 check("not removed: " + each, !map.containsValue(t) );
327 check(String.format("remove: map empty. size=%d", map.size()),
328 (map.size() == 0) && map.isEmpty());
331 private static <T> void testEntriesIteratorRemove(Map<T, T> map, String keys_desc, T[] keys) {
332 check(String.format("remove: map expected size m%d != k%d", map.size(), keys.length),
333 map.size() == keys.length);
335 Iterator<Map.Entry<T,T>> each = map.entrySet().iterator();
341 check("not removed: " + each, (map instanceof IdentityHashMap) || !map.entrySet().contains(t) );
342 check("not removed: " + each, !map.containsKey(key) );
343 check("not removed: " + each, !map.containsValue(value));
346 check(String.format("remove: map empty. size=%d", map.size()),
347 (map.size() == 0) && map.isEmpty());