java.util.concurrent.ConcurrentHashMap.entryForHash()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(179)

本文整理了Java中java.util.concurrent.ConcurrentHashMap.entryForHash()方法的一些代码示例,展示了ConcurrentHashMap.entryForHash()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ConcurrentHashMap.entryForHash()方法的具体详情如下:
包路径:java.util.concurrent.ConcurrentHashMap
类名称:ConcurrentHashMap
方法名:entryForHash

ConcurrentHashMap.entryForHash介绍

[英]Gets the table entry for the given segment and hash code.
[中]获取给定段和哈希代码的表项。

代码示例

代码示例来源:origin: robovm/robovm

HashEntry<K,V> first = entryForHash(this, hash);
HashEntry<K,V> e = first;
int retries = -1;
       (f = entryForHash(this, hash)) != first) {
    e = first = f;
    retries = -1;

代码示例来源:origin: robovm/robovm

final boolean replace(K key, int hash, V oldValue, V newValue) {
  if (!tryLock())
    scanAndLock(key, hash);
  boolean replaced = false;
  try {
    HashEntry<K,V> e;
    for (e = entryForHash(this, hash); e != null; e = e.next) {
      K k;
      if ((k = e.key) == key ||
        (e.hash == hash && key.equals(k))) {
        if (oldValue.equals(e.value)) {
          e.value = newValue;
          ++modCount;
          replaced = true;
        }
        break;
      }
    }
  } finally {
    unlock();
  }
  return replaced;
}

代码示例来源:origin: robovm/robovm

HashEntry<K,V> first = entryForHash(this, hash);
HashEntry<K,V> e = first;
HashEntry<K,V> node = null;
       (f = entryForHash(this, hash)) != first) {

代码示例来源:origin: robovm/robovm

final V replace(K key, int hash, V value) {
  if (!tryLock())
    scanAndLock(key, hash);
  V oldValue = null;
  try {
    HashEntry<K,V> e;
    for (e = entryForHash(this, hash); e != null; e = e.next) {
      K k;
      if ((k = e.key) == key ||
        (e.hash == hash && key.equals(k))) {
        oldValue = e.value;
        e.value = value;
        ++modCount;
        break;
      }
    }
  } finally {
    unlock();
  }
  return oldValue;
}

代码示例来源:origin: ibinti/bugvm

final boolean replace(K key, int hash, V oldValue, V newValue) {
  if (!tryLock())
    scanAndLock(key, hash);
  boolean replaced = false;
  try {
    HashEntry<K,V> e;
    for (e = entryForHash(this, hash); e != null; e = e.next) {
      K k;
      if ((k = e.key) == key ||
        (e.hash == hash && key.equals(k))) {
        if (oldValue.equals(e.value)) {
          e.value = newValue;
          ++modCount;
          replaced = true;
        }
        break;
      }
    }
  } finally {
    unlock();
  }
  return replaced;
}

代码示例来源:origin: MobiVM/robovm

final boolean replace(K key, int hash, V oldValue, V newValue) {
  if (!tryLock())
    scanAndLock(key, hash);
  boolean replaced = false;
  try {
    HashEntry<K,V> e;
    for (e = entryForHash(this, hash); e != null; e = e.next) {
      K k;
      if ((k = e.key) == key ||
        (e.hash == hash && key.equals(k))) {
        if (oldValue.equals(e.value)) {
          e.value = newValue;
          ++modCount;
          replaced = true;
        }
        break;
      }
    }
  } finally {
    unlock();
  }
  return replaced;
}

代码示例来源:origin: com.bugvm/bugvm-rt

final boolean replace(K key, int hash, V oldValue, V newValue) {
  if (!tryLock())
    scanAndLock(key, hash);
  boolean replaced = false;
  try {
    HashEntry<K,V> e;
    for (e = entryForHash(this, hash); e != null; e = e.next) {
      K k;
      if ((k = e.key) == key ||
        (e.hash == hash && key.equals(k))) {
        if (oldValue.equals(e.value)) {
          e.value = newValue;
          ++modCount;
          replaced = true;
        }
        break;
      }
    }
  } finally {
    unlock();
  }
  return replaced;
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

final boolean replace(K key, int hash, V oldValue, V newValue) {
  if (!tryLock())
    scanAndLock(key, hash);
  boolean replaced = false;
  try {
    HashEntry<K,V> e;
    for (e = entryForHash(this, hash); e != null; e = e.next) {
      K k;
      if ((k = e.key) == key ||
        (e.hash == hash && key.equals(k))) {
        if (oldValue.equals(e.value)) {
          e.value = newValue;
          ++modCount;
          replaced = true;
        }
        break;
      }
    }
  } finally {
    unlock();
  }
  return replaced;
}

代码示例来源:origin: com.jtransc/jtransc-rt

final boolean replace(K key, int hash, V oldValue, V newValue) {
  if (!tryLock())
    scanAndLock(key, hash);
  boolean replaced = false;
  try {
    HashEntry<K, V> e;
    for (e = entryForHash(this, hash); e != null; e = e.next) {
      K k;
      if ((k = e.key) == key ||
        (e.hash == hash && key.equals(k))) {
        if (oldValue.equals(e.value)) {
          e.value = newValue;
          ++modCount;
          replaced = true;
        }
        break;
      }
    }
  } finally {
    unlock();
  }
  return replaced;
}

代码示例来源:origin: com.gluonhq/robovm-rt

final boolean replace(K key, int hash, V oldValue, V newValue) {
  if (!tryLock())
    scanAndLock(key, hash);
  boolean replaced = false;
  try {
    HashEntry<K,V> e;
    for (e = entryForHash(this, hash); e != null; e = e.next) {
      K k;
      if ((k = e.key) == key ||
        (e.hash == hash && key.equals(k))) {
        if (oldValue.equals(e.value)) {
          e.value = newValue;
          ++modCount;
          replaced = true;
        }
        break;
      }
    }
  } finally {
    unlock();
  }
  return replaced;
}

代码示例来源:origin: org.codehaus.jsr166-mirror/jsr166

final boolean replace(K key, int hash, V oldValue, V newValue) {
  if (!tryLock())
    scanAndLock(key, hash);
  boolean replaced = false;
  try {
    HashEntry<K,V> e;
    for (e = entryForHash(this, hash); e != null; e = e.next) {
      K k;
      if ((k = e.key) == key ||
        (e.hash == hash && key.equals(k))) {
        if (oldValue.equals(e.value)) {
          e.value = newValue;
          ++modCount;
          replaced = true;
        }
        break;
      }
    }
  } finally {
    unlock();
  }
  return replaced;
}

代码示例来源:origin: MobiVM/robovm

final V replace(K key, int hash, V value) {
  if (!tryLock())
    scanAndLock(key, hash);
  V oldValue = null;
  try {
    HashEntry<K,V> e;
    for (e = entryForHash(this, hash); e != null; e = e.next) {
      K k;
      if ((k = e.key) == key ||
        (e.hash == hash && key.equals(k))) {
        oldValue = e.value;
        e.value = value;
        ++modCount;
        break;
      }
    }
  } finally {
    unlock();
  }
  return oldValue;
}

代码示例来源:origin: com.jtransc/jtransc-rt

final V replace(K key, int hash, V value) {
  if (!tryLock())
    scanAndLock(key, hash);
  V oldValue = null;
  try {
    HashEntry<K, V> e;
    for (e = entryForHash(this, hash); e != null; e = e.next) {
      K k;
      if ((k = e.key) == key ||
        (e.hash == hash && key.equals(k))) {
        oldValue = e.value;
        e.value = value;
        ++modCount;
        break;
      }
    }
  } finally {
    unlock();
  }
  return oldValue;
}

代码示例来源:origin: FlexoVM/flexovm

final boolean replace(K key, int hash, V oldValue, V newValue) {
  if (!tryLock())
    scanAndLock(key, hash);
  boolean replaced = false;
  try {
    HashEntry<K,V> e;
    for (e = entryForHash(this, hash); e != null; e = e.next) {
      K k;
      if ((k = e.key) == key ||
        (e.hash == hash && key.equals(k))) {
        if (oldValue.equals(e.value)) {
          e.value = newValue;
          ++modCount;
          replaced = true;
        }
        break;
      }
    }
  } finally {
    unlock();
  }
  return replaced;
}

代码示例来源:origin: FlexoVM/flexovm

final V replace(K key, int hash, V value) {
  if (!tryLock())
    scanAndLock(key, hash);
  V oldValue = null;
  try {
    HashEntry<K,V> e;
    for (e = entryForHash(this, hash); e != null; e = e.next) {
      K k;
      if ((k = e.key) == key ||
        (e.hash == hash && key.equals(k))) {
        oldValue = e.value;
        e.value = value;
        ++modCount;
        break;
      }
    }
  } finally {
    unlock();
  }
  return oldValue;
}

代码示例来源:origin: ibinti/bugvm

final V replace(K key, int hash, V value) {
  if (!tryLock())
    scanAndLock(key, hash);
  V oldValue = null;
  try {
    HashEntry<K,V> e;
    for (e = entryForHash(this, hash); e != null; e = e.next) {
      K k;
      if ((k = e.key) == key ||
        (e.hash == hash && key.equals(k))) {
        oldValue = e.value;
        e.value = value;
        ++modCount;
        break;
      }
    }
  } finally {
    unlock();
  }
  return oldValue;
}

代码示例来源:origin: com.gluonhq/robovm-rt

final V replace(K key, int hash, V value) {
  if (!tryLock())
    scanAndLock(key, hash);
  V oldValue = null;
  try {
    HashEntry<K,V> e;
    for (e = entryForHash(this, hash); e != null; e = e.next) {
      K k;
      if ((k = e.key) == key ||
        (e.hash == hash && key.equals(k))) {
        oldValue = e.value;
        e.value = value;
        ++modCount;
        break;
      }
    }
  } finally {
    unlock();
  }
  return oldValue;
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

final V replace(K key, int hash, V value) {
  if (!tryLock())
    scanAndLock(key, hash);
  V oldValue = null;
  try {
    HashEntry<K,V> e;
    for (e = entryForHash(this, hash); e != null; e = e.next) {
      K k;
      if ((k = e.key) == key ||
        (e.hash == hash && key.equals(k))) {
        oldValue = e.value;
        e.value = value;
        ++modCount;
        break;
      }
    }
  } finally {
    unlock();
  }
  return oldValue;
}

代码示例来源:origin: com.bugvm/bugvm-rt

final V replace(K key, int hash, V value) {
  if (!tryLock())
    scanAndLock(key, hash);
  V oldValue = null;
  try {
    HashEntry<K,V> e;
    for (e = entryForHash(this, hash); e != null; e = e.next) {
      K k;
      if ((k = e.key) == key ||
        (e.hash == hash && key.equals(k))) {
        oldValue = e.value;
        e.value = value;
        ++modCount;
        break;
      }
    }
  } finally {
    unlock();
  }
  return oldValue;
}

代码示例来源:origin: org.codehaus.jsr166-mirror/jsr166

final V replace(K key, int hash, V value) {
  if (!tryLock())
    scanAndLock(key, hash);
  V oldValue = null;
  try {
    HashEntry<K,V> e;
    for (e = entryForHash(this, hash); e != null; e = e.next) {
      K k;
      if ((k = e.key) == key ||
        (e.hash == hash && key.equals(k))) {
        oldValue = e.value;
        e.value = value;
        ++modCount;
        break;
      }
    }
  } finally {
    unlock();
  }
  return oldValue;
}

相关文章