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

泸州免费做网站重庆百度竞价推广

泸州免费做网站,重庆百度竞价推广,建筑工程招聘网,怎么把网站封包做app一、put方法的流程图 二、put方法的执行步骤 首先#xff0c;根据key值计算哈希值。然后判断table数组是否为空或者数组长度是否为0#xff0c;是的话则要扩容#xff0c;resize#xff08;#xff09;。接着#xff0c;根据哈希值计算数组下标。如果这个下标位置为空根据key值计算哈希值。然后判断table数组是否为空或者数组长度是否为0是的话则要扩容resize。接着根据哈希值计算数组下标。如果这个下标位置为空添加元素即可。如果这个下标位置不为空则判断此下标位置的首元素的key值与要添加元素的key值是否相同相同的话就直接覆盖元素。不相同的话则判断首元素是否为树节点是的话则向这个红黑树中插入元素在红黑树中插入一个新节点时首先会遍历树以找到这个新节点应该插入的位置。在这个遍历过程中也会检查是否已经存在相同key值的节点。如果存在也会覆盖元素不存在则新节点会被插入到正确的位置。如果是链表的话那就需要遍历链表看key是否已经存在存在则覆盖元素不存在则在链表尾部插入元素。插入之后如果链表长度大于等于8则需要把链表转换为红黑树。最后待所有元素处理完之后还要判断容量是否超过阈值超过了则需要扩容。 三、对应源码 /*** Computes key.hashCode() and spreads (XORs) higher bits of hash* to lower. Because the table uses power-of-two masking, sets of* hashes that vary only in bits above the current mask will* always collide. (Among known examples are sets of Float keys* holding consecutive whole numbers in small tables.) So we* apply a transform that spreads the impact of higher bits* downward. There is a tradeoff between speed, utility, and* quality of bit-spreading. Because many common sets of hashes* are already reasonably distributed (so dont benefit from* spreading), and because we use trees to handle large sets of* collisions in bins, we just XOR some shifted bits in the* cheapest possible way to reduce systematic lossage, as well as* to incorporate impact of the highest bits that would otherwise* never be used in index calculations because of table bounds.*/static final int hash(Object key) {//1.首先根据key值计算哈希值。int h;return (key null) ? 0 : (h key.hashCode()) ^ (h 16);}/*** Associates the specified value with the specified key in this map.* If the map previously contained a mapping for the key, the old* value is replaced.** param key key with which the specified value is to be associated* param value value to be associated with the specified key* return the previous value associated with ttkey/tt, or* ttnull/tt if there was no mapping for ttkey/tt.* (A ttnull/tt return can also indicate that the map* previously associated ttnull/tt with ttkey/tt.)*/public V put(K key, V value) {return putVal(hash(key), key, value, false, true);//hash值}/*** Implements Map.put and related methods.** param hash hash for key* param key the key* param value the value to put* param onlyIfAbsent if true, dont change existing value* param evict if false, the table is in creation mode.* return previous value, or null if none*/final V putVal(int hash, K key, V value, boolean onlyIfAbsent,boolean evict) {NodeK,V[] tab; NodeK,V p; int n, i;//2.然后判断table数组是否为空或者数组长度是否为0是的话则要扩容resize。if ((tab table) null || (n tab.length) 0)n (tab resize()).length;//3.接着根据哈希值计算数组下标。 //4.如果这个下标位置为空添加元素即可。if ((p tab[i (n - 1) hash]) null)tab[i] newNode(hash, key, value, null);else {//5.如果这个下标位置不为空则判断此下标位置的首元素的key值与要添加元素的key值是否相同相同的话就直接覆盖元素。NodeK,V e; K k;if (p.hash hash ((k p.key) key || (key ! null key.equals(k))))e p;//6.不相同的话则判断首元素是否为树节点是的话则向这个红黑树中插入元素else if (p instanceof TreeNode)e ((TreeNodeK,V)p).putTreeVal(this, tab, hash, key, value);//7.如果是链表的话那就需要遍历链表看key是否已经存在存在则覆盖元素不存在则在链表尾部插入元素。不存在则在链表尾部插入元素。插入之后如果链表长度大于等于8则需要把链表转换为红黑树。else {for (int binCount 0; ; binCount) {if ((e p.next) null) {p.next newNode(hash, key, value, null);if (binCount TREEIFY_THRESHOLD - 1) // -1 for 1sttreeifyBin(tab, hash);//转为红黑树break;}if (e.hash hash ((k e.key) key || (key ! null key.equals(k))))break;p e;}}if (e ! null) { // existing mapping for keyV oldValue e.value;if (!onlyIfAbsent || oldValue null)e.value value;afterNodeAccess(e);return oldValue;}}modCount;//8.最后待所有元素处理完之后还要判断容量是否超过阈值超过了则需要扩容。if (size threshold)resize();afterNodeInsertion(evict);return null;}
http://www.hkea.cn/news/14311810/

相关文章:

  • 公司免费建网站网站排名带照片怎么做
  • 静海网站建设制作wordpress 手机版主题
  • 天马网络 网站建设网络推广方案下拉管家xiala11
  • 个人网站 做啥好wordpress如何禁用谷歌地图
  • 阿里网站制作需要多少钱机械网站 英文
  • 定制化网站门户网站开发jz190
  • 中国风网站表现佛山论坛建站模板
  • 网站是否被k网站如何做等级保护
  • 在线网站做情侣头像中国建设银行官方网站下载安装
  • 站长之家网站素材wordpress title 8211
  • 深圳专业做公司网站找公司做网站需要注意什么
  • 泉州专业建站品牌ci设计
  • 网站建设费用价格明细表wordpress如何选择对应模板
  • 网站建设服务 杭州餐厅vi设计公司
  • 龙岩建网站搭建好ftp服务器 如何通过网站访问
  • 上传文章的网站app商城开发价格
  • 遂宁市建设局网站青海西宁高端网站建设
  • 专门做房产的网站做行业网站赚钱
  • 帮人做网站犯法wordpress页面透明度
  • 小公司网络组建规划seo服务顾问
  • 定制旅游网站建设方案网站搭建中114514
  • 网站切换中英文长沙房地产开发商排名
  • 外贸网站测速辽宁网站推广的目的
  • 网站建设的运营计划婚纱网站设计素材
  • 书城网站建设项目定义绍兴网站建设方案
  • app开发哪家公司比较专业沈阳专业seo关键词优化
  • 秦皇岛营销式网站微信公众号发文章教程
  • 网易云课堂的网站建设特点海南住房和城乡建设部网站
  • 做网站永久人力外包和劳务派遣哪个更好一些
  • 上海网站推广策划给网站底部做友情链接