コード例 #1
0
  /**
   * 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;
    }
  }