/**
  * Compares this map with another map for equality of their stored entries.
  *
  * @param other an <code>Object</code> value
  * @return true if the maps are identical
  */
 @Override // GemStoneAddition
 public boolean equals(Object other) {
   if (_map.equals(other)) {
     return true; // comparing two trove maps
   } else if (other instanceof Map) {
     Map that = (Map) other;
     if (that.size() != _map.size()) {
       return false; // different sizes, no need to compare
     } else { // now we have to do it the hard way
       Iterator it = that.entrySet().iterator();
       for (int i = that.size(); i-- > 0; ) {
         Map.Entry e = (Map.Entry) it.next();
         Object key = e.getKey();
         Object val = e.getValue();
         if (key instanceof Integer && val instanceof Integer) {
           int k = unwrapKey(key);
           int v = unwrapValue(val);
           if (_map.containsKey(k) && v == _map.get(k)) {
             // match, ok to continue
           } else {
             return false; // no match: we're done
           }
         } else {
           return false; // different type in other map
         }
       }
       return true; // all entries match
     }
   } else {
     return false;
   }
 }
 /**
  * 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.
  */
 @Override // GemStoneAddition
 public Object get(Object key) {
   int k = unwrapKey(key);
   int 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
  */
 @Override // GemStoneAddition
 public Object clone() {
   try {
     TIntIntHashMapDecorator copy = (TIntIntHashMapDecorator) super.clone();
     copy._map = (TIntIntHashMap) _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 Integer(0) if none was found.
  */
 @Override // GemStoneAddition
 public Object put(Object key, Object 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
  */
 @Override // GemStoneAddition
 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
  */
 @Override // GemStoneAddition
 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 Integer(0) if it was not found in the map
  */
 @Override // GemStoneAddition
 public Object remove(Object key) {
   return wrapValue(_map.remove(unwrapKey(key)));
 }