public D get(K key) { return content.containsKey(key) ? content.get(key).getValue() : null; }
public D get(K key) { return content.containsKey(key) ? content.get(key).getValue() : null; }
/** * If the counter of the key/value is greater than one, the counter is decreased. Otherwise, * the entry is removed and the value is cleaned up. */ public D remove(K key) { Count pair = content.get(key); if (pair == null) return null; if (pair.isLast()) { return removeAllOf(key); } return content.put(key, content.get(key).decrease()).getValue(); }
/** * If the counter of the key/value is greater than one, the counter is decreased. Otherwise, * the entry is removed and the value is cleaned up. */ public D remove(K key) { Count pair = content.get(key); if (pair == null) return null; if (pair.isLast()) { return removeAllOf(key); } return content.put(key, content.get(key).decrease()).getValue(); }
/** * If the key exists, the counter is increased. Otherwise, a value is created, and the * key/value pair is added to the map. */ public D put(K key) throws Exception { if (content.containsKey(key)) { return content.put(key, content.get(key).increase()).getValue(); } else { Count c = new Count(open(key)); content.put(key, c); return c.getValue(); } }
public K find(D value) { for (Map.Entry<K, Count> entry : content.entrySet()) { if (entry.getValue().getValue().equals(value)) { return entry.getKey(); } } return null; }
/** * If the key exists, the counter is increased. Otherwise, a value is created, and the * key/value pair is added to the map. */ public D put(K key) throws Exception { if (content.containsKey(key)) { return content.put(key, content.get(key).increase()).getValue(); } else { Count c = new Count(open(key)); content.put(key, c); return c.getValue(); } }
public K find(D value) { for (Map.Entry<K, Count> entry : content.entrySet()) { if (entry.getValue().getValue().equals(value)) { return entry.getKey(); } } return null; }