当前位置: 首页 > wzjs >正文

网站一键制作淄博网站制作优化

网站一键制作,淄博网站制作优化,网站开发php未来发展,建筑设计防火规范Jdk7不同集合的扩容机制 集合类初始容量负载因子扩容公式扩容时机ArrayList10无新容量 旧容量 1.5元素数量超过容量时HashMap160.75新容量 旧容量 2元素数量超过 容量 负载因子 时HashSet160.75新容量 旧容量 2元素数量超过 容量 负载因子 时Vector10无新容量 旧容量…

Jdk7不同集合的扩容机制

集合类初始容量负载因子扩容公式扩容时机
ArrayList10新容量 = 旧容量 × 1.5元素数量超过容量时
HashMap160.75新容量 = 旧容量 × 2元素数量超过 容量 × 负载因子
HashSet160.75新容量 = 旧容量 × 2元素数量超过 容量 × 负载因子
Vector10新容量 = 旧容量 + 增量 或 × 2元素数量超过容量时
Hashtable110.75新容量 = 旧容量 × 2 + 1元素数量超过 容量 × 负载因子

通过了解不同集合类的扩容机制,可以更好地选择和使用合适的集合类,避免频繁扩容带来的性能开销。

ArrayList

private void grow(int minCapacity) {// overflow-conscious codeint oldCapacity = elementData.length;// newCapacity = oldCapacity + oldCapacity / 2int newCapacity = oldCapacity + (oldCapacity >> 1);if (newCapacity - minCapacity < 0)newCapacity = minCapacity;if (newCapacity - MAX_ARRAY_SIZE > 0)newCapacity = hugeCapacity(minCapacity);// minCapacity is usually close to size, so this is a win:elementData = Arrays.copyOf(elementData, newCapacity);
}

HashMap

头插法

void addEntry(int hash, K key, V value, int bucketIndex) {if ((size >= threshold) && (null != table[bucketIndex])) {// 旧容量 * 2resize(2 * table.length);hash = (null != key) ? hash(key) : 0;bucketIndex = indexFor(hash, table.length);}createEntry(hash, key, value, bucketIndex);
}

HashSet

通过HashMap实现的.

public HashSet() {map = new HashMap<>();}

Hashtable

protected void rehash() {HashtableEntry e, old;int i, index;int oldCapacity = table.length;HashtableEntry oldTable[] = table;// 新容量 = 旧容量 × 2 + 1int newCapacity = oldCapacity * 2 + 1;HashtableEntry newTable[] = new HashtableEntry[newCapacity];threshold = (int)(newCapacity * loadFactor);table = newTable;for (i = oldCapacity ; i-- > 0 ;) {for (old = oldTable[i] ; old != null ; ) {e = old;old = old.next;index = (e.hash & 0x7FFFFFFF) % newCapacity;e.next = newTable[index];newTable[index] = e;}}
}

Vector

private void grow(int minCapacity) {// overflow-conscious codeint oldCapacity = elementData.length;int newCapacity = oldCapacity + ((capacityIncrement > 0) ?capacityIncrement : oldCapacity);if (newCapacity - minCapacity < 0)newCapacity = minCapacity;if (newCapacity - MAX_ARRAY_SIZE > 0)newCapacity = hugeCapacity(minCapacity);elementData = Arrays.copyOf(elementData, newCapacity);}
http://www.dtcms.com/wzjs/355438.html

相关文章:

  • 南京做网站牛企业如何开展网络营销
  • 荣耀商城seo职业
  • 北京移动官方网站百度推广开户费用多少
  • 亚马逊卖家可以做促销的网站兴安盟新百度县seo快速排名
  • wordpress p=优化建站
  • 石家庄做外贸网站建设全网推广代理
  • 石家庄有没有销售做被用的网站中国企业500强最新排名
  • 建站公司杭州无锡百度快速优化排名
  • 做爰网站美女应用商店aso
  • 四平网站建设公司十大营销案例分析
  • 广州网站制作功能百度搜索量查询
  • wordpress维护汕头网站优化
  • 网站建设一般要素营销案例网站
  • wordpress 滚动加载搜索引擎优化行业
  • 国外网页网站公司网站建设公司
  • 游戏网站seo怎么做网站推广软件免费版大全
  • 电子商务网站设计内容大数据营销系统软件
  • 潍坊做网站个人工作室免费服务器
  • 企业网站改版的好处怎样优化标题关键词
  • 苏州品牌网站制作公司seo网站怎么搭建
  • 服务器域名新余seo
  • 专业网站建设公司推荐广州google推广
  • app网站建设源码企业网站制作模板
  • 一般通过男网友宁波seo网站服务
  • 装饰设计师培训seo搜索引擎优化步骤
  • 百度网站上做推广受骗郑州网站营销推广公司
  • 现在的网站怎样做推广seo外链建设的方法
  • 口碑好的盐城网站建设广州seo推广
  • 公司网站域名是什么seo优化的网站
  • 和网站建设相关的行业微信指数官网