@Test public void removeAll() { Options<Integer> opt = new Options<Integer>(); opt.put(1, "one"); opt.put(2, "two"); opt.put(3, "three"); opt.put(4, "four"); assertEquals("opt.size()", 4, opt.size()); Set<Integer> remove = new HashSet<Integer>(); remove.add(1); remove.add(2); remove.add(4); Counter counter = new Counter(); opt.addOptionsListener(counter); opt.removeAll(remove); assertEquals("opt.size()", 1, opt.size()); assertEquals("counter.changed", 1, counter.changed); assertEquals("opt.get(1)", null, opt.get(1)); assertEquals("opt.get(2)", null, opt.get(2)); assertEquals("opt.get(3)", "three", opt.get(3)); assertEquals("opt.get(4)", null, opt.get(4)); }
public Set<String> removeAll(Set<K> keys) { LinkedHashSet<String> result = new LinkedHashSet<String>(); for (K key : keys) { String removed = map.remove(key); if (removed != null) { result.add(removed); } } if (!values.isEmpty()) { values.removeAll(result); this.fireChanged(); } return result; }
Options { public Set<String> removeAll(Set<K> keys) { LinkedHashSet<String> result = new LinkedHashSet<String>(); for (K key : keys) { String removed = map.remove(key); if (removed != null) { result.add(removed); } } if (!values.isEmpty()) { values.removeAll(result); this.fireChanged(); } return result; } }
Options { public Set<String> removeAll(Set<K> keys) { LinkedHashSet<String> result = new LinkedHashSet<String>(); for (K key : keys) { String removed = map.remove(key); if (removed != null) { result.add(removed); } } if (!values.isEmpty()) { values.removeAll(result); this.fireChanged(); } return result; }  }
Options { public Set<String> removeAll(Set<K> keys) { LinkedHashSet<String> result = new LinkedHashSet<String>(); for (K key : keys) { String removed = map.remove(key); if (removed != null) { result.add(removed); } } if (!values.isEmpty()) { values.removeAll(result); this.fireChanged(); } return result; }  Map<K, String> toMap(); void clear(); boolean containsKey(Object key); boolean containsValue(Object value); String get(Object key); K getKey(String value); boolean isEmpty(); Set<K> keySet(); String put(K key, String value); void putAll(Options other); void putAll(Map<K, String> aMap); String remove(Object key); Set<String> removeAll(Set<K> keys); int size(); Set<String> values(); String[] getValues(); int indexOf(String value); String getValue(int index); void addOptionsListener(OptionsListener l); void removeOptionsListener(OptionsListener l); static Options<T> create(T... values); }
Options { public Set<String> removeAll(Set<K> keys) { LinkedHashSet<String> result = new LinkedHashSet<String>(); for (K key : keys) { String removed = map.remove(key); if (removed != null) { result.add(removed); } } if (!values.isEmpty()) { values.removeAll(result); this.fireChanged(); } return result; }  Map<K, String> toMap(); void clear(); boolean containsKey(Object key); boolean containsValue(Object value); String get(Object key); K getKey(String value); boolean isEmpty(); Set<K> keySet(); String put(K key, String value); void putAll(Options other); void putAll(Map<K, String> aMap); String remove(Object key); Set<String> removeAll(Set<K> keys); int size(); Set<String> values(); String[] getValues(); int indexOf(String value); String getValue(int index); void addOptionsListener(OptionsListener l); void removeOptionsListener(OptionsListener l); static Options<T> create(T... values);  }