java.util.IdentityHashMap.findIndex()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(105)

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

IdentityHashMap.findIndex介绍

[英]Returns the index where the key is found at, or the index of the next empty spot if the key is not found in this table.
[中]返回在其中找到该键的索引,如果在此表中找不到该键,则返回下一个空位的索引。

代码示例

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

/**
 * Returns whether this map contains the specified key.
 *
 * @param key
 *            the key to search for.
 * @return {@code true} if this map contains the specified key,
 *         {@code false} otherwise.
 */
@Override
public boolean containsKey(Object key) {
  if (key == null) {
    key = NULL_OBJECT;
  }
  int index = findIndex(key, elementData);
  return elementData[index] == key;
}

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

private IdentityHashMapEntry<K, V> getEntry(Object key) {
  if (key == null) {
    key = NULL_OBJECT;
  }
  int index = findIndex(key, elementData);
  if (elementData[index] == key) {
    return getEntry(index);
  }
  return null;
}

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

/**
 * Returns the value of the mapping with the specified key.
 *
 * @param key
 *            the key.
 * @return the value of the mapping with the specified key.
 */
@Override
public V get(Object key) {
  if (key == null) {
    key = NULL_OBJECT;
  }
  int index = findIndex(key, elementData);
  if (elementData[index] == key) {
    Object result = elementData[index + 1];
    return massageValue(result);
  }
  return null;
}

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

int index = findIndex(_key, elementData);
  if (++size > threshold) {
    rehash();
    index = findIndex(_key, elementData);

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

private void rehash() {
  int newlength = elementData.length * 2;
  if (newlength == 0) {
    newlength = 1;
  }
  Object[] newData = newElementArray(newlength);
  for (int i = 0; i < elementData.length; i = i + 2) {
    Object key = elementData[i];
    if (key != null) {
      // if not empty
      int index = findIndex(key, newData);
      newData[index] = key;
      newData[index + 1] = elementData[i + 1];
    }
  }
  elementData = newData;
  computeMaxSize();
}

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

int index, next, hash;
Object result, object;
index = next = findIndex(key, elementData);

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

/**
 * Returns whether this map contains the specified key.
 *
 * @param key
 *            the key to search for.
 * @return {@code true} if this map contains the specified key,
 *         {@code false} otherwise.
 */
@Override
public boolean containsKey(Object key) {
  if (key == null) {
    key = NULL_OBJECT;
  }
  int index = findIndex(key, elementData);
  return elementData[index] == key;
}

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

/**
 * Returns whether this map contains the specified key.
 *
 * @param key
 *            the key to search for.
 * @return {@code true} if this map contains the specified key,
 *         {@code false} otherwise.
 */
@Override
public boolean containsKey(Object key) {
  if (key == null) {
    key = NULL_OBJECT;
  }
  int index = findIndex(key, elementData);
  return elementData[index] == key;
}

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

/**
 * Returns whether this map contains the specified key.
 *
 * @param key
 *            the key to search for.
 * @return {@code true} if this map contains the specified key,
 *         {@code false} otherwise.
 */
@Override
public boolean containsKey(Object key) {
  if (key == null) {
    key = NULL_OBJECT;
  }
  int index = findIndex(key, elementData);
  return elementData[index] == key;
}

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

/**
 * Returns whether this map contains the specified key.
 *
 * @param key
 *            the key to search for.
 * @return {@code true} if this map contains the specified key,
 *         {@code false} otherwise.
 */
@Override
public boolean containsKey(Object key) {
  if (key == null) {
    key = NULL_OBJECT;
  }
  int index = findIndex(key, elementData);
  return elementData[index] == key;
}

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

/**
 * Returns whether this map contains the specified key.
 *
 * @param key
 *            the key to search for.
 * @return {@code true} if this map contains the specified key,
 *         {@code false} otherwise.
 */
@Override
public boolean containsKey(Object key) {
  if (key == null) {
    key = NULL_OBJECT;
  }
  int index = findIndex(key, elementData);
  return elementData[index] == key;
}

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

private IdentityHashMapEntry<K, V> getEntry(Object key) {
  if (key == null) {
    key = NULL_OBJECT;
  }
  int index = findIndex(key, elementData);
  if (elementData[index] == key) {
    return getEntry(index);
  }
  return null;
}

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

private IdentityHashMapEntry<K, V> getEntry(Object key) {
  if (key == null) {
    key = NULL_OBJECT;
  }
  int index = findIndex(key, elementData);
  if (elementData[index] == key) {
    return getEntry(index);
  }
  return null;
}

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

private IdentityHashMapEntry<K, V> getEntry(Object key) {
  if (key == null) {
    key = NULL_OBJECT;
  }
  int index = findIndex(key, elementData);
  if (elementData[index] == key) {
    return getEntry(index);
  }
  return null;
}

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

private IdentityHashMapEntry<K, V> getEntry(Object key) {
  if (key == null) {
    key = NULL_OBJECT;
  }
  int index = findIndex(key, elementData);
  if (elementData[index] == key) {
    return getEntry(index);
  }
  return null;
}

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

private IdentityHashMapEntry<K, V> getEntry(Object key) {
  if (key == null) {
    key = NULL_OBJECT;
  }
  int index = findIndex(key, elementData);
  if (elementData[index] == key) {
    return getEntry(index);
  }
  return null;
}

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

private IdentityHashMapEntry<K, V> getEntry(Object key) {
  if (key == null) {
    key = NULL_OBJECT;
  }
  int index = findIndex(key, elementData);
  if (elementData[index] == key) {
    return getEntry(index);
  }
  return null;
}

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

private IdentityHashMapEntry<K, V> getEntry(Object key) {
  if (key == null) {
    key = NULL_OBJECT;
  }
  int index = findIndex(key, elementData);
  if (elementData[index] == key) {
    return getEntry(index);
  }
  return null;
}

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

/**
 * Returns the value of the mapping with the specified key.
 *
 * @param key
 *            the key.
 * @return the value of the mapping with the specified key.
 */
@Override
public V get(Object key) {
  if (key == null) {
    key = NULL_OBJECT;
  }
  int index = findIndex(key, elementData);
  if (elementData[index] == key) {
    Object result = elementData[index + 1];
    return massageValue(result);
  }
  return null;
}

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

private void rehash() {
  int newlength = elementData.length * 2;
  if (newlength == 0) {
    newlength = 1;
  }
  Object[] newData = newElementArray(newlength);
  for (int i = 0; i < elementData.length; i = i + 2) {
    Object key = elementData[i];
    if (key != null) {
      // if not empty
      int index = findIndex(key, newData);
      newData[index] = key;
      newData[index + 1] = elementData[i + 1];
    }
  }
  elementData = newData;
  computeMaxSize();
}

相关文章