boolean replace(K key, int hash, V oldValue, V newValue) {
      lock();
      try {
        int c = count;
        HashEntry[] tab = table;
        int index = hash & (tab.length - 1);
        HashEntry<K, V> first = (HashEntry<K, V>) tab[index];
        HashEntry<K, V> e = first;
        for (; ; ) {
          if (e == null) return false;
          if (e.hash == hash && key.equals(e.key)) break;
          e = e.next;
        }

        V v = e.value;
        if (v == null || !oldValue.equals(v)) return false;

        e.value = newValue;
        count = c; // write-volatile
        return true;

      } finally {
        unlock();
      }
    }
 public int hashCode() {
   return ((key == null) ? 0 : key.hashCode()) ^ ((value == null) ? 0 : value.hashCode());
 }
 public boolean contains(Object o) {
   if (!(o instanceof Map.Entry)) return false;
   Map.Entry<K, V> e = (Map.Entry<K, V>) o;
   V v = ConcurrentHashMap.this.get(e.getKey());
   return v != null && v.equals(e.getValue());
 }