java.util.HashMap.ensureCapacity()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(137)

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

HashMap.ensureCapacity介绍

[英]Ensures that the hash table has sufficient capacity to store the specified number of mappings, with room to grow. If not, it increases the capacity as appropriate. Like doubleCapacity, this method moves existing entries to new buckets as appropriate. Unlike doubleCapacity, this method can grow the table by factors of 2^n for n > 1. Hopefully, a single call to this method will be faster than multiple calls to doubleCapacity.

This method is called only by putAll.
[中]

代码示例

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

/**
 * Copies all the mappings in the specified map to this map. These mappings
 * will replace all mappings that this map had for any of the keys currently
 * in the given map.
 *
 * @param map
 *            the map to copy mappings from.
 */
@Override public void putAll(Map<? extends K, ? extends V> map) {
  ensureCapacity(map.size());
  super.putAll(map);
}

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

/**
 * Copies all the mappings in the specified map to this map. These mappings
 * will replace all mappings that this map had for any of the keys currently
 * in the given map.
 *
 * @param map
 *            the map to copy mappings from.
 */
@Override public void putAll(Map<? extends K, ? extends V> map) {
  ensureCapacity(map.size());
  super.putAll(map);
}

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

/**
 * Copies all the mappings in the specified map to this map. These mappings
 * will replace all mappings that this map had for any of the keys currently
 * in the given map.
 *
 * @param map
 *            the map to copy mappings from.
 */
@Override public void putAll(Map<? extends K, ? extends V> map) {
  ensureCapacity(map.size());
  super.putAll(map);
}

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

/**
 * Copies all the mappings in the specified map to this map. These mappings
 * will replace all mappings that this map had for any of the keys currently
 * in the given map.
 *
 * @param map
 *            the map to copy mappings from.
 */
@Override public void putAll(Map<? extends K, ? extends V> map) {
  ensureCapacity(map.size());
  super.putAll(map);
}

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

/**
 * Copies all the mappings in the specified map to this map. These mappings
 * will replace all mappings that this map had for any of the keys currently
 * in the given map.
 *
 * @param map
 *            the map to copy mappings from.
 */
@Override public void putAll(Map<? extends K, ? extends V> map) {
  ensureCapacity(map.size());
  super.putAll(map);
}

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

/**
 * Copies all the mappings in the specified map to this map. These mappings
 * will replace all mappings that this map had for any of the keys currently
 * in the given map.
 *
 * @param map
 *            the map to copy mappings from.
 */
@Override public void putAll(Map<? extends K, ? extends V> map) {
  ensureCapacity(map.size());
  super.putAll(map);
}

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

/**
 * Copies all the mappings in the specified map to this map. These mappings
 * will replace all mappings that this map had for any of the keys currently
 * in the given map.
 *
 * @param map
 *            the map to copy mappings from.
 */
@Override public void putAll(Map<? extends K, ? extends V> map) {
  ensureCapacity(map.size());
  super.putAll(map);
}

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

/**
 * Copies all the mappings in the specified map to this map. These mappings
 * will replace all mappings that this map had for any of the keys currently
 * in the given map.
 *
 * @param map
 *            the map to copy mappings from.
 */
@Override public void putAll(Map<? extends K, ? extends V> map) {
  ensureCapacity(map.size());
  super.putAll(map);
}

相关文章