/** * 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 final Object get(Object key) { int index = index(key); return index < 0 ? null : _values[index]; }
/** * Deletes a key/value pair from the map. * * @param key an <code>Object</code> value * @return an <code>Object</code> value */ public final Object remove(Object key) { Object prev = null; int index = index(key); if (index >= 0) { prev = _values[index]; removeAt(index); // clear key,state; adjust size } return prev; }
@Override // GemStoneAddition public boolean remove(Object entry) { // have to effectively reimplement Map.remove here // because we need to return true/false depending on // whether the removal took place. Since the Entry's // value can be null, this means that we can't rely // on the value of the object returned by Map.remove() // to determine whether a deletion actually happened. // // Note also that the deletion is only legal if // both the key and the value match. Object key, val; int index; key = keyForEntry(entry); index = index(key); if (index >= 0) { val = valueForEntry(entry); if (val == _values[index] || (null != val && val.equals(_values[index]))) { removeAt(index); // clear key,state; adjust size return true; } } return false; }