@Test public void testListMap() { ListMap<String, String> listMap = new ListMap<String, String>(); listMap.put("bob", "hello"); assert "hello".equals(listMap.get("bob")); assert "hello".equals(listMap.remove("bob")); assert listMap.size() == 0; assert listMap.isEmpty(); listMap.put("abc", "1"); listMap.put("def", "2"); listMap.put("ghi", "3"); listMap.put("jkl", "4"); listMap.put("mno", "5"); assert "3".equals(listMap.get("ghi")); assert listMap.size() == 5; assert !listMap.isEmpty(); for (int i = 0; i < listMap.size(); i++) { String expectedValue = Integer.toString(i + 1); String key = listMap.getKey(i); String value = listMap.getValue(i); Entry<String, String> entry = listMap.getEntry(i); assert key.equals(entry.getKey()); assert value.equals(entry.getValue()); assert expectedValue.equals(value); } }
@SuppressWarnings("unchecked") public ListMap(){ entries = new ListMapEntry[4]; backingMap = new HashMap<K, V>(4); }
ListMap extends AbstractMap<K, V> implements Cloneable, Serializable { @SuppressWarnings("unchecked") public ListMap(){ entries = new ListMapEntry[4]; backingMap = new HashMap<K, V>(4); } }
ListMap extends AbstractMap<K, V> implements Cloneable, Serializable { @SuppressWarnings("unchecked") public ListMap(){ entries = new ListMapEntry[4]; backingMap = new HashMap<K, V>(4); } @SuppressWarnings("unchecked")  ListMap(); @SuppressWarnings("unchecked")  ListMap(int initialCapacity); @SuppressWarnings("unchecked")  ListMap(Map<? extends K, ? extends V> map); }
ListMap extends AbstractMap<K, V> implements Cloneable, Serializable { @SuppressWarnings("unchecked") public ListMap(){ entries = new ListMapEntry[4]; backingMap = new HashMap<K, V>(4); } @SuppressWarnings("unchecked")  ListMap(); @SuppressWarnings("unchecked")  ListMap(int initialCapacity); @SuppressWarnings("unchecked")  ListMap(Map<? extends K, ? extends V> map); @Override int size(); Entry<K, V> getEntry(int index); V getValue(int index); K getKey(int index); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override V get(Object key); @Override @SuppressWarnings("unchecked") V put(K key, V value); @Override V remove(Object key); @Override void putAll(Map<? extends K, ? extends V> map); @Override void clear(); @Override ListMap<K, V> clone(); @Override Set<K> keySet(); @Override Collection<V> values(); @Override Set<Entry<K, V>> entrySet(); }
ListMap extends AbstractMap<K, V> implements Cloneable, Serializable { @SuppressWarnings("unchecked") public ListMap(){ entries = new ListMapEntry[4]; backingMap = new HashMap<K, V>(4); } @SuppressWarnings("unchecked")  ListMap(); @SuppressWarnings("unchecked")  ListMap(int initialCapacity); @SuppressWarnings("unchecked")  ListMap(Map<? extends K, ? extends V> map); @Override int size(); Entry<K, V> getEntry(int index); V getValue(int index); K getKey(int index); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override V get(Object key); @Override @SuppressWarnings("unchecked") V put(K key, V value); @Override V remove(Object key); @Override void putAll(Map<? extends K, ? extends V> map); @Override void clear(); @Override ListMap<K, V> clone(); @Override Set<K> keySet(); @Override Collection<V> values(); @Override Set<Entry<K, V>> entrySet();  }