/** * 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(); Object k = unwrapKey(key); float v = unwrapValue(val); if (_map.containsKey(k) && v == _map.get(k)) { // match, ok to continue } else { return false; // no match: we're done } } 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) { Object k = unwrapKey(key); float 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); } }