public static boolean containsAllEntries(final InternalCharCharMapOps map, Map<?, ?> another) { if (map == another) throw new IllegalArgumentException(); if (another instanceof CharCharMap) { CharCharMap m2 = (CharCharMap) another; if (map.size() < m2.size()) return false; if (m2 instanceof InternalCharCharMapOps) { //noinspection unchecked return ((InternalCharCharMapOps) m2).allEntriesContainingIn(map); } return m2.forEachWhile(new CharCharPredicate() { @Override public boolean test(char a, char b) { return map.containsEntry(a, b); } }); } for (Map.Entry<?, ?> e : another.entrySet()) { if (!map.containsEntry((Character) e.getKey(), (Character) e.getValue())) return false; } return true; }
public static void putAll(final InternalCharCharMapOps map, Map<? extends Character, ? extends Character> another) { if (map == another) throw new IllegalArgumentException(); long maxPossibleSize = map.sizeAsLong() + Containers.sizeAsLong(another); map.ensureCapacity(maxPossibleSize); if (another instanceof CharCharMap) { if (another instanceof InternalCharCharMapOps) { ((InternalCharCharMapOps) another).reversePutAllTo(map); } else { ((CharCharMap) another).forEach(new CharCharConsumer() { @Override public void accept(char key, char value) { map.justPut(key, value); } }); } } else { for (Map.Entry<? extends Character, ? extends Character> e : another.entrySet()) { map.justPut(e.getKey(), e.getValue()); } } }
public static void putAll(final InternalCharCharMapOps map, Map<? extends Character, ? extends Character> another) { if (map == another) throw new IllegalArgumentException(); long maxPossibleSize = map.sizeAsLong() + Containers.sizeAsLong(another); map.ensureCapacity(maxPossibleSize); if (another instanceof CharCharMap) { if (another instanceof InternalCharCharMapOps) { ((InternalCharCharMapOps) another).reversePutAllTo(map); } else { ((CharCharMap) another).forEach(new CharCharConsumer() { @Override public void accept(char key, char value) { map.justPut(key, value); } }); } } else { for (Map.Entry<? extends Character, ? extends Character> e : another.entrySet()) { map.justPut(e.getKey(), e.getValue()); } } }
public static boolean containsAllEntries(final InternalCharCharMapOps map, Map<?, ?> another) { if (map == another) throw new IllegalArgumentException(); if (another instanceof CharCharMap) { CharCharMap m2 = (CharCharMap) another; if (map.size() < m2.size()) return false; if (m2 instanceof InternalCharCharMapOps) { //noinspection unchecked return ((InternalCharCharMapOps) m2).allEntriesContainingIn(map); } return m2.forEachWhile(new CharCharPredicate() { @Override public boolean test(char a, char b) { return map.containsEntry(a, b); } }); } for (Map.Entry<?, ?> e : another.entrySet()) { if (!map.containsEntry((Character) e.getKey(), (Character) e.getValue())) return false; } return true; }