@Override public Collection<V> remove(Object key) { Collection<V> result = get(key); deltaMap.put( ErasureUtils.<K>uncheckedCast(key), ErasureUtils.<Collection<V>>uncheckedCast(removedValue)); return result; }
/** This is more expensive than normal. */ @Override public void clear() { // iterate over all keys in originalMap and set them to null in deltaMap for (K key : originalMap.keySet()) { deltaMap.put(key, ErasureUtils.<Collection<V>>uncheckedCast(removedValue)); } }
/** * Adds the value to the collection given by map.get(key). A new collection is created using the * supplied CollectionFactory. */ public static <K, V, C extends Collection<V>> void putIntoValueCollection( Map<K, C> map, K key, V value, CollectionFactory<V> cf) { C c = map.get(key); if (c == null) { c = ErasureUtils.<C>uncheckedCast(cf.newCollection()); map.put(key, c); } c.add(value); }
@SuppressWarnings("unchecked") @Override public boolean equals(Object o) { if (!(o instanceof Map.Entry)) { return false; } Map.Entry e = ErasureUtils.uncheckedCast(o); return eq(key, e.getKey()) && eq(value, e.getValue()); }
/** * Reduces memory consumption to the minimum for representing the values currently stored stored * in this object. */ public void compact() { if (keys.length > size) { Class[] newKeys = new Class[size]; Object[] newValues = new Object[size]; System.arraycopy(keys, 0, newKeys, 0, size); System.arraycopy(values, 0, newValues, 0, size); keys = ErasureUtils.uncheckedCast(newKeys); values = newValues; } }
public void setCapacity(int newSize) { if (size > newSize) { throw new RuntimeException("You cannot set capacity to smaller than the current size."); } Class[] newKeys = new Class[newSize]; Object[] newValues = new Object[newSize]; System.arraycopy(keys, 0, newKeys, 0, size); System.arraycopy(values, 0, newValues, 0, size); keys = ErasureUtils.uncheckedCast(newKeys); values = newValues; }
public Class<Pair<Integer, Integer>> getType() { return ErasureUtils.<Class<Pair<Integer, Integer>>>uncheckedCast(Pair.class); }
public Class<Throwable> getType() { return ErasureUtils.uncheckedCast(Throwable.class); }
public Class<SortedSet<Pair<CoreLabel, String>>> getType() { return ErasureUtils.uncheckedCast(SortedSet.class); }
public Class<List<CoreLabel>> getType() { return ErasureUtils.<Class<List<CoreLabel>>>uncheckedCast(List.class); }
public Class<Pair<String, Double>> getType() { return ErasureUtils.uncheckedCast(Pair.class); }
public Class<List<List<Pair<String, Pair>>>> getType() { return ErasureUtils.uncheckedCast(List.class); }
public Class<List<Pair<Triple<String, String, String>, String>>> getType() { return ErasureUtils.uncheckedCast(List.class); }
public Class<List<Pair<WordLemmaTag, String>>> getType() { return ErasureUtils.uncheckedCast(List.class); }
/** * Initializes this ArrayCoreMap, pre-allocating arrays to hold up to capacity key,value pairs. * This array will grow if necessary. * * @param capacity Initial capacity of object in key,value pairs */ public ArrayCoreMap(int capacity) { keys = ErasureUtils.uncheckedCast(new Class[capacity]); values = new Object[capacity]; // size starts at 0 }
public Class<HashMap<Integer, String>> getType() { return ErasureUtils.<Class<HashMap<Integer, String>>>uncheckedCast(Pair.class); }
public Class<HashMap<String, String>> getType() { return ErasureUtils.uncheckedCast(HashMap.class); }
public Class<Map<String, Double>> getType() { return ErasureUtils.uncheckedCast(Map.class); }
public Class<List<CoreMap>> getType() { return ErasureUtils.uncheckedCast(List.class); }
public Class<List<IntPair>> getType() { return ErasureUtils.uncheckedCast(List.class); }