/** * Retrieves the value for <tt>key</tt> * * @param key an <code>Object</code> value * @return the value of <tt>key</tt> or null if no such mapping exists. */ public Short get(Short key) { short k = unwrapKey(key); short v = _map.get(k); // 0 may be a false positive since primitive maps // cannot return null, so we have to do an extra // check here. if (v == 0) { return _map.containsKey(k) ? wrapValue(v) : null; } else { return wrapValue(v); } }
/** * Clones the underlying trove collection and returns the clone wrapped in a new decorator * instance. This is a shallow clone except where primitives are concerned. * * @return a copy of the receiver */ public TShortShortHashMapDecorator clone() { try { TShortShortHashMapDecorator copy = (TShortShortHashMapDecorator) super.clone(); copy._map = (TShortShortHashMap) _map.clone(); return copy; } catch (CloneNotSupportedException e) { // assert(false); throw new InternalError(); // we are cloneable, so this does not happen } }
/** * Inserts a key/value pair into the map. * * @param key an <code>Object</code> value * @param value an <code>Object</code> value * @return the previous value associated with <tt>key</tt>, or Short(0) if none was found. */ public Short put(Short key, Short value) { return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); }
/** * Checks for the present of <tt>key</tt> in the keys of the map. * * @param key an <code>Object</code> value * @return a <code>boolean</code> value */ public boolean containsKey(Object key) { return _map.containsKey(unwrapKey(key)); }
/** * Checks for the presence of <tt>val</tt> in the values of the map. * * @param val an <code>Object</code> value * @return a <code>boolean</code> value */ public boolean containsValue(Object val) { return _map.containsValue(unwrapValue(val)); }
/** * Deletes a key/value pair from the map. * * @param key an <code>Object</code> value * @return the removed value, or Short(0) if it was not found in the map */ public Short remove(Short key) { return wrapValue(_map.remove(unwrapKey(key))); }