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

x33g5p2x  于2022-01-19 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(125)

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

Hashtable.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.
[中]确保哈希表有足够的容量来存储指定数量的映射,并有增长空间。如果没有,它将酌情增加容量。与doubleCapacity一样,此方法将现有条目移动到新的存储桶(视情况而定)。与doubleCapacity不同,当n>1时,此方法可以将表增长2^n倍。希望对该方法的一次调用比对doubleCapacity的多次调用更快。
此方法仅由putAll调用。

代码示例

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

/**
 * Copies every mapping to this {@code Hashtable} from the specified map.
 *
 * @param map
 *            the map to copy mappings from.
 */
public synchronized void putAll(Map<? extends K, ? extends V> map) {
  ensureCapacity(map.size());
  for (Entry<? extends K, ? extends V> e : map.entrySet()) {
    put(e.getKey(), e.getValue());
  }
}

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

/**
 * Copies every mapping to this {@code Hashtable} from the specified map.
 *
 * @param map
 *            the map to copy mappings from.
 */
public synchronized void putAll(Map<? extends K, ? extends V> map) {
  ensureCapacity(map.size());
  for (Entry<? extends K, ? extends V> e : map.entrySet()) {
    put(e.getKey(), e.getValue());
  }
}

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

/**
 * Copies every mapping to this {@code Hashtable} from the specified map.
 *
 * @param map
 *            the map to copy mappings from.
 */
public synchronized void putAll(Map<? extends K, ? extends V> map) {
  ensureCapacity(map.size());
  for (Entry<? extends K, ? extends V> e : map.entrySet()) {
    put(e.getKey(), e.getValue());
  }
}

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

/**
 * Copies every mapping to this {@code Hashtable} from the specified map.
 *
 * @param map
 *            the map to copy mappings from.
 */
public synchronized void putAll(Map<? extends K, ? extends V> map) {
  ensureCapacity(map.size());
  for (Entry<? extends K, ? extends V> e : map.entrySet()) {
    put(e.getKey(), e.getValue());
  }
}

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

/**
 * Copies every mapping to this {@code Hashtable} from the specified map.
 *
 * @param map
 *            the map to copy mappings from.
 */
public synchronized void putAll(Map<? extends K, ? extends V> map) {
  ensureCapacity(map.size());
  for (Entry<? extends K, ? extends V> e : map.entrySet()) {
    put(e.getKey(), e.getValue());
  }
}

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

/**
 * Copies every mapping to this {@code Hashtable} from the specified map.
 *
 * @param map
 *            the map to copy mappings from.
 */
public synchronized void putAll(Map<? extends K, ? extends V> map) {
  ensureCapacity(map.size());
  for (Entry<? extends K, ? extends V> e : map.entrySet()) {
    put(e.getKey(), e.getValue());
  }
}

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

/**
 * Copies every mapping to this {@code Hashtable} from the specified map.
 *
 * @param map
 *            the map to copy mappings from.
 */
public synchronized void putAll(Map<? extends K, ? extends V> map) {
  ensureCapacity(map.size());
  for (Entry<? extends K, ? extends V> e : map.entrySet()) {
    put(e.getKey(), e.getValue());
  }
}

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

/**
 * Copies every mapping to this {@code Hashtable} from the specified map.
 *
 * @param map
 *            the map to copy mappings from.
 */
public synchronized void putAll(Map<? extends K, ? extends V> map) {
  ensureCapacity(map.size());
  for (Entry<? extends K, ? extends V> e : map.entrySet()) {
    put(e.getKey(), e.getValue());
  }
}

相关文章