@Test public void testDelete() { MyIterableHashMap<String, Integer> map = new MyIterableHashMap<>(); int n = map.size(); String key = "foo"; int x = 42; map.put(key, x); assertEquals(x, map.get(key).intValue()); assertEquals(n + 1, map.size()); map.delete(key); assertNull(map.get(key)); assertEquals(n, map.size()); }
@Override public void delete(K key) { int i = index(key); if(data[i] == null){ return; } List<Entry> list = data[i]; for(int j=0; j<list.size(); j++){ Entry entry = list.get(j); if(key.equals(entry.key)){ list.remove(j); modificationCounter++; return; } } }
MyIterableHashMap implements MyHashMap<K,V>, Iterable<V> { @Override public void delete(K key) { int i = index(key); if(data[i] == null){ return; } List<Entry> list = data[i]; for(int j=0; j<list.size(); j++){ Entry entry = list.get(j); if(key.equals(entry.key)){ list.remove(j); modificationCounter++; return; } } } }
MyIterableHashMap implements MyHashMap<K,V>, Iterable<V> { @Override public void delete(K key) { int i = index(key); if(data[i] == null){ return; } List<Entry> list = data[i]; for(int j=0; j<list.size(); j++){ Entry entry = list.get(j); if(key.equals(entry.key)){ list.remove(j); modificationCounter++; return; } } } MyIterableHashMap();  MyIterableHashMap(int capacity); }
MyIterableHashMap implements MyHashMap<K,V>, Iterable<V> { @Override public void delete(K key) { int i = index(key); if(data[i] == null){ return; } List<Entry> list = data[i]; for(int j=0; j<list.size(); j++){ Entry entry = list.get(j); if(key.equals(entry.key)){ list.remove(j); modificationCounter++; return; } } } MyIterableHashMap();  MyIterableHashMap(int capacity); @Override Iterator<V> iterator(); @Override void put(K key, V value); @Override void delete(K key); @Override V get(K key); @Override int size(); }
MyIterableHashMap implements MyHashMap<K,V>, Iterable<V> { @Override public void delete(K key) { int i = index(key); if(data[i] == null){ return; } List<Entry> list = data[i]; for(int j=0; j<list.size(); j++){ Entry entry = list.get(j); if(key.equals(entry.key)){ list.remove(j); modificationCounter++; return; } } } MyIterableHashMap();  MyIterableHashMap(int capacity); @Override Iterator<V> iterator(); @Override void put(K key, V value); @Override void delete(K key); @Override V get(K key); @Override int size();  }