void removeLastTwo(List<Map> maps) {
Map first = maps.get(0); int size = first.size();
Iterator fit = first.keySet().iterator(); for (int j = 0; j < size - 2; j++)
fit.next();
Object x1 = fit.next();
Object x2 = fit.next();
for (Map map : maps) {
Iterator it = map.keySet().iterator(); while (it.hasNext()) {
Object x = it.next(); if (x == x1 || x == x2)
it.remove();
}
}
mapsEqual(maps);
}
void remove(Map m, Iterator it) { int size = m.size();
it.remove(); if (m.size() != size-1) thrownew Error(String.format("Incorrect size!%nmap=%s, size=%d%n",
m.toString(), m.size()));
}
void test(String[] args) throws Throwable { finalint iterations = 100; final Random r = new Random();
for (int i = 0; i < iterations; i++) {
List<Map> maps = List.of( new IdentityHashMap(11), new HashMap(16), new LinkedHashMap(16), new WeakHashMap(16), new Hashtable(16), new TreeMap(), new ConcurrentHashMap(16), new ConcurrentSkipListMap(),
Collections.checkedMap(new HashMap(16), Integer.class, Integer.class),
Collections.checkedSortedMap(new TreeMap(), Integer.class, Integer.class),
Collections.checkedNavigableMap(new TreeMap(), Integer.class, Integer.class),
Collections.synchronizedMap(new HashMap(16)),
Collections.synchronizedSortedMap(new TreeMap()),
Collections.synchronizedNavigableMap(new TreeMap()));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.