com.carrotsearch.hppc.ObjectIntHashMap.allocateThenInsertThenRehash()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(58)

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

ObjectIntHashMap.allocateThenInsertThenRehash介绍

[英]This method is invoked when there is a new key/ value pair to be inserted into the buffers but there is not enough empty slots to do so. New buffers are allocated. If this succeeds, we know we can proceed with rehashing so we assign the pending element to the previous buffer (possibly violating the invariant of having at least one empty slot) and rehash all keys, substituting new buffers at the end.
[中]当有一个新的键/值对要插入缓冲区,但没有足够的空插槽插入时,就会调用此方法。分配了新的缓冲区。如果成功,我们知道我们可以继续进行重新设置,因此我们将挂起的元素分配给前一个缓冲区(可能违反了至少有一个空槽的不变量),并重新设置所有密钥,最后替换新的缓冲区。

代码示例

代码示例来源:origin: carrotsearch/hppc

/**
 * {@inheritDoc}
 */
@Override
public void indexInsert(int index, KType key, int value) {
 assert index < 0 : "The index must not point at an existing key.";
 index = ~index;
 if (((key) == null)) {
  assert index == mask + 1;
  values[index] = value;
  hasEmptyKey = true;
 } else {
  assert ((keys[index]) == null);
  if (assigned == resizeAt) {
   allocateThenInsertThenRehash(index, key, value);
  } else {
   keys[index] = key;
   values[index] = value;
  }
  assigned++;
 }
}

代码示例来源:origin: carrotsearch/hppc

allocateThenInsertThenRehash(slot, key, value);
} else {
 keys[slot] = key;

代码示例来源:origin: harbby/presto-connectors

/**
 * {@inheritDoc}
 */
@Override
public void indexInsert(int index, KType key, int value) {
 assert index < 0 : "The index must not point at an existing key.";
 index = ~index;
 if (((key) == null)) {
  assert index == mask + 1;
  values[index] = value;
  hasEmptyKey = true;
 } else {
  assert ((keys[index]) == null);
  if (assigned == resizeAt) {
   allocateThenInsertThenRehash(index, key, value);
  } else {
   keys[index] = key;
   values[index] = value;
  }
  assigned++;
 }
}

代码示例来源:origin: harbby/presto-connectors

allocateThenInsertThenRehash(slot, key, value);
} else {
 keys[slot] = key;

相关文章