网易首页 > 网易号 > 正文 申请入驻

详解ConcurrentHashMap

0
分享至

[] tab = table;;) {\r","marks":[]}]}]},{"type":"block","id":"zXUf-1663834759349","name":"code-line","data":{},"nodes":[{"type":"text","id":"At2R-1663834759348","leaves":[{"text":" Node f; int n, i, fh;\r","marks":[]}]}]},{"type":"block","id":"uZZb-1663834759352","name":"code-line","data":{},"nodes":[{"type":"text","id":"X7HK-1663834759351","leaves":[{"text":" //容器为空进行初始化流程\r","marks":[]}]}]},{"type":"block","id":"XCCZ-1663834759354","name":"code-line","data":{},"nodes":[{"type":"text","id":"0pVv-1663834759353","leaves":[{"text":" if (tab == null || (n = tab.length) == 0)\r","marks":[]}]}]},{"type":"block","id":"nNgE-1663834759356","name":"code-line","data":{},"nodes":[{"type":"text","id":"agml-1663834759355","leaves":[{"text":" tab = initTable();\r","marks":[]}]}]},{"type":"block","id":"dyAB-1663834759358","name":"code-line","data":{},"nodes":[{"type":"text","id":"bu6i-1663834759357","leaves":[{"text":" //如果槽位中为空的 \r","marks":[]}]}]},{"type":"block","id":"twAJ-1663834759360","name":"code-line","data":{},"nodes":[{"type":"text","id":"xZmZ-1663834759359","leaves":[{"text":" else if ((f = tabAt(tab, i = (n - 1) & hash)) == null) {\r","marks":[]}]}]},{"type":"block","id":"V9wq-1663834759362","name":"code-line","data":{},"nodes":[{"type":"text","id":"ryUb-1663834759361","leaves":[{"text":" //以cas方式进行替换,替换成功就中断循环,替换失败则进行下一次循环\r","marks":[]}]}]},{"type":"block","id":"vw20-1663834759364","name":"code-line","data":{},"nodes":[{"type":"text","id":"IqdQ-1663834759363","leaves":[{"text":" if (casTabAt(tab, i, null,\r","marks":[]}]}]},{"type":"block","id":"7sMM-1663834759366","name":"code-line","data":{},"nodes":[{"type":"text","id":"7StE-1663834759365","leaves":[{"text":" new Node(hash, key, value, null)))\r","marks":[]}]}]},{"type":"block","id":"WvJB-1663834759368","name":"code-line","data":{},"nodes":[{"type":"text","id":"unP3-1663834759367","leaves":[{"text":" break; // no lock when adding to empty bin\r","marks":[]}]}]},{"type":"block","id":"G8c4-1663834759370","name":"code-line","data":{},"nodes":[{"type":"text","id":"AI4m-1663834759369","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"4WP4-1663834759372","name":"code-line","data":{},"nodes":[{"type":"text","id":"Rl8r-1663834759371","leaves":[{"text":" //一种特殊的节点(forwarding 节点,迁移节点,只在迁移过程中存在)的处理方式\r","marks":[]}]}]},{"type":"block","id":"eTc2-1663834759374","name":"code-line","data":{},"nodes":[{"type":"text","id":"Bh6Q-1663834759373","leaves":[{"text":" else if ((fh = f.hash) == MOVED)\r","marks":[]}]}]},{"type":"block","id":"Pc9K-1663834759376","name":"code-line","data":{},"nodes":[{"type":"text","id":"0HEM-1663834759375","leaves":[{"text":" //帮助进行扩容\r","marks":[]}]}]},{"type":"block","id":"iLeY-1663834759378","name":"code-line","data":{},"nodes":[{"type":"text","id":"Y4pU-1663834759377","leaves":[{"text":" tab = helpTransfer(tab, f);\r","marks":[]}]}]},{"type":"block","id":"VnnD-1663834759380","name":"code-line","data":{},"nodes":[{"type":"text","id":"5pau-1663834759379","leaves":[{"text":" //如果槽位不为空,并且不是(forwarding节点) \r","marks":[]}]}]},{"type":"block","id":"lN1a-1663834759382","name":"code-line","data":{},"nodes":[{"type":"text","id":"rnqL-1663834759381","leaves":[{"text":" else {\r","marks":[]}]}]},{"type":"block","id":"DWIQ-1663834759384","name":"code-line","data":{},"nodes":[{"type":"text","id":"NyrQ-1663834759383","leaves":[{"text":" V oldVal = null;\r","marks":[]}]}]},{"type":"block","id":"o9sk-1663834759386","name":"code-line","data":{},"nodes":[{"type":"text","id":"pGTo-1663834759385","leaves":[{"text":" //将整个槽位锁住\r","marks":[]}]}]},{"type":"block","id":"rCti-1663834759388","name":"code-line","data":{},"nodes":[{"type":"text","id":"NAYN-1663834759387","leaves":[{"text":" synchronized (f) {\r","marks":[]}]}]},{"type":"block","id":"oyjk-1663834759390","name":"code-line","data":{},"nodes":[{"type":"text","id":"oCk7-1663834759389","leaves":[{"text":" //double check,如果槽位里面的数据发生变更则重新走流程\r","marks":[]}]}]},{"type":"block","id":"BURV-1663834759392","name":"code-line","data":{},"nodes":[{"type":"text","id":"04BJ-1663834759391","leaves":[{"text":" if (tabAt(tab, i) == f) {\r","marks":[]}]}]},{"type":"block","id":"SShs-1663834759394","name":"code-line","data":{},"nodes":[{"type":"text","id":"1DOR-1663834759393","leaves":[{"text":" //如果是链表\r","marks":[]}]}]},{"type":"block","id":"hA1B-1663834759396","name":"code-line","data":{},"nodes":[{"type":"text","id":"lZDF-1663834759395","leaves":[{"text":" if (fh >= 0) {\r","marks":[]}]}]},{"type":"block","id":"Rtfa-1663834759398","name":"code-line","data":{},"nodes":[{"type":"text","id":"cMwe-1663834759397","leaves":[{"text":" binCount = 1;\r","marks":[]}]}]},{"type":"block","id":"F8Qm-1663834759400","name":"code-line","data":{},"nodes":[{"type":"text","id":"P23C-1663834759399","leaves":[{"text":" for (Node e = f;; ++binCount) {\r","marks":[]}]}]},{"type":"block","id":"mpYw-1663834759402","name":"code-line","data":{},"nodes":[{"type":"text","id":"wv6U-1663834759401","leaves":[{"text":" K ek;\r","marks":[]}]}]},{"type":"block","id":"Gv53-1663834759404","name":"code-line","data":{},"nodes":[{"type":"text","id":"elFb-1663834759403","leaves":[{"text":" //如果存在成员则覆盖\r","marks":[]}]}]},{"type":"block","id":"ePie-1663834759406","name":"code-line","data":{},"nodes":[{"type":"text","id":"jiZz-1663834759405","leaves":[{"text":" if (e.hash == hash &&\r","marks":[]}]}]},{"type":"block","id":"7oTc-1663834759408","name":"code-line","data":{},"nodes":[{"type":"text","id":"WTmt-1663834759407","leaves":[{"text":" ((ek = e.key) == key ||\r","marks":[]}]}]},{"type":"block","id":"a9bU-1663834759410","name":"code-line","data":{},"nodes":[{"type":"text","id":"bpcY-1663834759409","leaves":[{"text":" (ek != null && key.equals(ek)))) {\r","marks":[]}]}]},{"type":"block","id":"d07i-1663834759412","name":"code-line","data":{},"nodes":[{"type":"text","id":"TMUY-1663834759411","leaves":[{"text":" oldVal = e.val;\r","marks":[]}]}]},{"type":"block","id":"DM71-1663834759414","name":"code-line","data":{},"nodes":[{"type":"text","id":"mx1g-1663834759413","leaves":[{"text":" if (!onlyIfAbsent)\r","marks":[]}]}]},{"type":"block","id":"9iWN-1663834759416","name":"code-line","data":{},"nodes":[{"type":"text","id":"OX4l-1663834759415","leaves":[{"text":" e.val = value;\r","marks":[]}]}]},{"type":"block","id":"drWO-1663834759418","name":"code-line","data":{},"nodes":[{"type":"text","id":"Jaky-1663834759417","leaves":[{"text":" break;\r","marks":[]}]}]},{"type":"block","id":"1DNE-1663834759420","name":"code-line","data":{},"nodes":[{"type":"text","id":"miRk-1663834759419","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"Gz6Z-1663834759423","name":"code-line","data":{},"nodes":[{"type":"text","id":"Tj27-1663834759422","leaves":[{"text":" //不存在成员则新增\r","marks":[]}]}]},{"type":"block","id":"ZjF0-1663834759425","name":"code-line","data":{},"nodes":[{"type":"text","id":"CbfQ-1663834759424","leaves":[{"text":" Node pred = e;\r","marks":[]}]}]},{"type":"block","id":"Ll8I-1663834759427","name":"code-line","data":{},"nodes":[{"type":"text","id":"KpkL-1663834759426","leaves":[{"text":" if ((e = e.next) == null) {\r","marks":[]}]}]},{"type":"block","id":"793G-1663834759429","name":"code-line","data":{},"nodes":[{"type":"text","id":"BoWL-1663834759428","leaves":[{"text":" pred.next = new Node(hash, key,\r","marks":[]}]}]},{"type":"block","id":"MiCY-1663834759431","name":"code-line","data":{},"nodes":[{"type":"text","id":"dpXi-1663834759430","leaves":[{"text":" value, null);\r","marks":[]}]}]},{"type":"block","id":"yOlD-1663834759433","name":"code-line","data":{},"nodes":[{"type":"text","id":"ZmB6-1663834759432","leaves":[{"text":" break;\r","marks":[]}]}]},{"type":"block","id":"q3sM-1663834759435","name":"code-line","data":{},"nodes":[{"type":"text","id":"0Fqy-1663834759434","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"EuFw-1663834759437","name":"code-line","data":{},"nodes":[{"type":"text","id":"iaBq-1663834759436","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"5MZd-1663834759439","name":"code-line","data":{},"nodes":[{"type":"text","id":"Io7t-1663834759438","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"1WNk-1663834759441","name":"code-line","data":{},"nodes":[{"type":"text","id":"76j2-1663834759440","leaves":[{"text":" //如果是红黑树\r","marks":[]}]}]},{"type":"block","id":"UVZ7-1663834759443","name":"code-line","data":{},"nodes":[{"type":"text","id":"yKlr-1663834759442","leaves":[{"text":" else if (f instanceof TreeBin) {\r","marks":[]}]}]},{"type":"block","id":"Vyk4-1663834759445","name":"code-line","data":{},"nodes":[{"type":"text","id":"IsEb-1663834759444","leaves":[{"text":" Node p;\r","marks":[]}]}]},{"type":"block","id":"XePT-1663834759447","name":"code-line","data":{},"nodes":[{"type":"text","id":"oz8r-1663834759446","leaves":[{"text":" binCount = 2;\r","marks":[]}]}]},{"type":"block","id":"6YbY-1663834759449","name":"code-line","data":{},"nodes":[{"type":"text","id":"AC5d-1663834759448","leaves":[{"text":" if ((p = ((TreeBin)f).putTreeVal(hash, key,\r","marks":[]}]}]},{"type":"block","id":"DAjc-1663834759451","name":"code-line","data":{},"nodes":[{"type":"text","id":"r5Bs-1663834759450","leaves":[{"text":" value)) != null) {\r","marks":[]}]}]},{"type":"block","id":"Bs7W-1663834759453","name":"code-line","data":{},"nodes":[{"type":"text","id":"Wg4g-1663834759452","leaves":[{"text":" oldVal = p.val;\r","marks":[]}]}]},{"type":"block","id":"m5bq-1663834759455","name":"code-line","data":{},"nodes":[{"type":"text","id":"JC8E-1663834759454","leaves":[{"text":" if (!onlyIfAbsent)\r","marks":[]}]}]},{"type":"block","id":"2wHD-1663834759457","name":"code-line","data":{},"nodes":[{"type":"text","id":"1Pk4-1663834759456","leaves":[{"text":" p.val = value;\r","marks":[]}]}]},{"type":"block","id":"zsxM-1663834759459","name":"code-line","data":{},"nodes":[{"type":"text","id":"wSbp-1663834759458","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"f7Cv-1663834759461","name":"code-line","data":{},"nodes":[{"type":"text","id":"CUY8-1663834759460","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"CcoM-1663834759463","name":"code-line","data":{},"nodes":[{"type":"text","id":"V2Q9-1663834759462","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"Unow-1663834759465","name":"code-line","data":{},"nodes":[{"type":"text","id":"xRP2-1663834759464","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"cjXH-1663834759467","name":"code-line","data":{},"nodes":[{"type":"text","id":"1sy9-1663834759466","leaves":[{"text":" //如果一个槽位中的数量大于1(只有大于1的才会有binCount)\r","marks":[]}]}]},{"type":"block","id":"Iktq-1663834759469","name":"code-line","data":{},"nodes":[{"type":"text","id":"00i1-1663834759468","leaves":[{"text":" if (binCount != 0) {\r","marks":[]}]}]},{"type":"block","id":"7nGt-1663834759471","name":"code-line","data":{},"nodes":[{"type":"text","id":"Xwfd-1663834759470","leaves":[{"text":" //如果槽位中的成员数量大于等于8,则变更为\r","marks":[]}]}]},{"type":"block","id":"bpQp-1663834759473","name":"code-line","data":{},"nodes":[{"type":"text","id":"lcu0-1663834759472","leaves":[{"text":" if (binCount >= TREEIFY_THRESHOLD)\r","marks":[]}]}]},{"type":"block","id":"1PwQ-1663834759475","name":"code-line","data":{},"nodes":[{"type":"text","id":"qlkH-1663834759474","leaves":[{"text":" //进行转换成红黑树处理\r","marks":[]}]}]},{"type":"block","id":"llRS-1663834759477","name":"code-line","data":{},"nodes":[{"type":"text","id":"VZsL-1663834759476","leaves":[{"text":" treeifyBin(tab, i);\r","marks":[]}]}]},{"type":"block","id":"wiw0-1663834759479","name":"code-line","data":{},"nodes":[{"type":"text","id":"i9qj-1663834759478","leaves":[{"text":" if (oldVal != null)\r","marks":[]}]}]},{"type":"block","id":"MMFJ-1663834759481","name":"code-line","data":{},"nodes":[{"type":"text","id":"80Wc-1663834759480","leaves":[{"text":" return oldVal;\r","marks":[]}]}]},{"type":"block","id":"kaIT-1663834759483","name":"code-line","data":{},"nodes":[{"type":"text","id":"TToL-1663834759482","leaves":[{"text":" break;\r","marks":[]}]}]},{"type":"block","id":"D0kf-1663834759485","name":"code-line","data":{},"nodes":[{"type":"text","id":"oD8i-1663834759484","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"oxXj-1663834759487","name":"code-line","data":{},"nodes":[{"type":"text","id":"u7lP-1663834759486","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"C7Ro-1663834759489","name":"code-line","data":{},"nodes":[{"type":"text","id":"Ml6d-1663834759488","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"840p-1663834759491","name":"code-line","data":{},"nodes":[{"type":"text","id":"iYpQ-1663834759490","leaves":[{"text":" addCount(1L, binCount);\r","marks":[]}]}]},{"type":"block","id":"3Bkb-1663834759493","name":"code-line","data":{},"nodes":[{"type":"text","id":"2qct-1663834759492","leaves":[{"text":" return null;\r","marks":[]}]}]},{"type":"block","id":"FGSC-1663834759496","name":"code-line","data":{},"nodes":[{"type":"text","id":"78ZU-1663834759494","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"44Qt-1663834759498","name":"code-line","data":{},"nodes":[{"type":"text","id":"PJv1-1663834759497","leaves":[{"text":"","marks":[]}]}]}],"state":{"language":"java"}},{"type":"block","id":"Pa7n-1663834758402","name":"heading","data":{"version":1,"level":"h2"},"nodes":[{"type":"text","id":"8Dhy-1663834758403","leaves":[{"text":"spread()方法,获取槽位。","marks":[]}]}],"state":{}},{"type":"block","id":"SEid-1663834768358","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"UPjN-1663834768357","leaves":[{"text":"作用:用于获取槽位值","marks":[]}]}],"state":{}},{"type":"block","id":"h0G2-1663834779109","name":"code","data":{"wrap":false,"language":"","theme":"default"},"nodes":[{"type":"block","id":"GZiq-1663834779108","name":"code-line","data":{},"nodes":[{"type":"text","id":"caj6-1663834769885","leaves":[{"text":"static final int spread(int h) {\r","marks":[]}]}]},{"type":"block","id":"UJjm-1663834779583","name":"code-line","data":{},"nodes":[{"type":"text","id":"Ju7F-1663834779582","leaves":[{"text":" //h为key值得hash值,将高16位也参与运算,然后与int最大值进行&运算(效果为将值变为正数,其他位置不变)\r","marks":[]}]}]},{"type":"block","id":"wjNQ-1663834779585","name":"code-line","data":{},"nodes":[{"type":"text","id":"XJBC-1663834779584","leaves":[{"text":" //HASH_BITS为int最大值,最高位为0\r","marks":[]}]}]},{"type":"block","id":"I03F-1663834779587","name":"code-line","data":{},"nodes":[{"type":"text","id":"2tfF-1663834779586","leaves":[{"text":" //HashMap中没有处理为正数的步骤,这里负数有其它含义,查看节点类型\r","marks":[]}]}]},{"type":"block","id":"Wndo-1663834779589","name":"code-line","data":{},"nodes":[{"type":"text","id":"mThA-1663834779588","leaves":[{"text":" return (h ^ (h >>> 16)) & HASH_BITS;\r","marks":[]}]}]},{"type":"block","id":"VJVv-1663834779591","name":"code-line","data":{},"nodes":[{"type":"text","id":"NZA4-1663834779590","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"pji2-1663834779593","name":"code-line","data":{},"nodes":[{"type":"text","id":"A1pa-1663834779592","leaves":[{"text":"","marks":[]}]}]}],"state":{"language":"java"}},{"type":"block","id":"JW4e-1663834779110","name":"heading","data":{"version":1,"level":"h2"},"nodes":[{"type":"text","id":"kXcB-1663834779111","leaves":[{"text":"initTable()方法,初始化容器","marks":[]}]}],"state":{}},{"type":"block","id":"HHAw-1663834784985","name":"code","data":{"version":1,"language":"","theme":"default"},"nodes":[{"type":"block","id":"vrqb-1663834784978","name":"code-line","data":{},"nodes":[{"type":"text","id":"LunG-1663834784977","leaves":[{"text":"","marks":[]}]}]},{"type":"block","id":"5j0a-1663834784980","name":"code-line","data":{},"nodes":[{"type":"text","id":"g9SQ-1663834784979","leaves":[{"text":" private final Node[] initTable() {\r","marks":[]}]}]},{"type":"block","id":"vtbI-1663834790449","name":"code-line","data":{},"nodes":[{"type":"text","id":"rxI6-1663834790448","leaves":[{"text":" Node[] tab; int sc;\r","marks":[]}]}]},{"type":"block","id":"JEqd-1663834790451","name":"code-line","data":{},"nodes":[{"type":"text","id":"XmpX-1663834790450","leaves":[{"text":" while ((tab = table) == null || tab.length == 0) {\r","marks":[]}]}]},{"type":"block","id":"NVF2-1663834790453","name":"code-line","data":{},"nodes":[{"type":"text","id":"O617-1663834790452","leaves":[{"text":" //sizeCtl,代表着初始化资源或者扩容资源的锁,必须要获取到该锁才允许进行初始化或者扩容的操作\r","marks":[]}]}]},{"type":"block","id":"F2LM-1663834790455","name":"code-line","data":{},"nodes":[{"type":"text","id":"wo8v-1663834790454","leaves":[{"text":" if ((sc = sizeCtl) < 0)\r","marks":[]}]}]},{"type":"block","id":"oeDe-1663834790457","name":"code-line","data":{},"nodes":[{"type":"text","id":"IxVm-1663834790456","leaves":[{"text":" //放弃当前cpu的使用权,让出时间片,线程计入就绪状态参与竞争\r","marks":[]}]}]},{"type":"block","id":"Z2Wp-1663834790459","name":"code-line","data":{},"nodes":[{"type":"text","id":"W3bI-1663834790458","leaves":[{"text":" Thread.yield(); // lost initialization race; just spin\r","marks":[]}]}]},{"type":"block","id":"mtlw-1663834790462","name":"code-line","data":{},"nodes":[{"type":"text","id":"Hey5-1663834790461","leaves":[{"text":" //比较并尝试将sizeCtl替换成-1,如果失败则继续循环 \r","marks":[]}]}]},{"type":"block","id":"pTOd-1663834790464","name":"code-line","data":{},"nodes":[{"type":"text","id":"duJ0-1663834790463","leaves":[{"text":" else if (U.compareAndSwapInt(this, SIZECTL, sc, -1)) {\r","marks":[]}]}]},{"type":"block","id":"APkD-1663834790466","name":"code-line","data":{},"nodes":[{"type":"text","id":"lOOo-1663834790465","leaves":[{"text":" try {\r","marks":[]}]}]},{"type":"block","id":"U6iV-1663834790468","name":"code-line","data":{},"nodes":[{"type":"text","id":"GxFV-1663834790467","leaves":[{"text":" //进行一次double check 防止在进入分支前,容器发生了变更\r","marks":[]}]}]},{"type":"block","id":"6nbs-1663834790470","name":"code-line","data":{},"nodes":[{"type":"text","id":"R7NT-1663834790469","leaves":[{"text":" if ((tab = table) == null || tab.length == 0) {\r","marks":[]}]}]},{"type":"block","id":"gzI7-1663834790472","name":"code-line","data":{},"nodes":[{"type":"text","id":"h7OC-1663834790471","leaves":[{"text":" int n = (sc > 0) ? sc : DEFAULT_CAPACITY;\r","marks":[]}]}]},{"type":"block","id":"vU69-1663834790474","name":"code-line","data":{},"nodes":[{"type":"text","id":"JV4Z-1663834790473","leaves":[{"text":" @SuppressWarnings(\"unchecked\")\r","marks":[]}]}]},{"type":"block","id":"mrXK-1663834790476","name":"code-line","data":{},"nodes":[{"type":"text","id":"9q6D-1663834790475","leaves":[{"text":" //初始化容器\r","marks":[]}]}]},{"type":"block","id":"D1PF-1663834790478","name":"code-line","data":{},"nodes":[{"type":"text","id":"CJfv-1663834790477","leaves":[{"text":" Node[] nt = (Node[])new Node[n];\r","marks":[]}]}]},{"type":"block","id":"bqyR-1663834790480","name":"code-line","data":{},"nodes":[{"type":"text","id":"8e06-1663834790479","leaves":[{"text":" table = tab = nt;\r","marks":[]}]}]},{"type":"block","id":"mosO-1663834790482","name":"code-line","data":{},"nodes":[{"type":"text","id":"uW7C-1663834790481","leaves":[{"text":" sc = n - (n >>> 2);\r","marks":[]}]}]},{"type":"block","id":"83un-1663834790484","name":"code-line","data":{},"nodes":[{"type":"text","id":"9W9K-1663834790483","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"Sq0h-1663834790486","name":"code-line","data":{},"nodes":[{"type":"text","id":"LtMQ-1663834790485","leaves":[{"text":" } finally {\r","marks":[]}]}]},{"type":"block","id":"muhz-1663834790488","name":"code-line","data":{},"nodes":[{"type":"text","id":"D1Zx-1663834790487","leaves":[{"text":" sizeCtl = sc;\r","marks":[]}]}]},{"type":"block","id":"xvzD-1663834790490","name":"code-line","data":{},"nodes":[{"type":"text","id":"vk9I-1663834790489","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"pDRk-1663834790492","name":"code-line","data":{},"nodes":[{"type":"text","id":"GcHN-1663834790491","leaves":[{"text":" break;\r","marks":[]}]}]},{"type":"block","id":"hOkk-1663834790494","name":"code-line","data":{},"nodes":[{"type":"text","id":"Wgx4-1663834790493","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"sQUs-1663834790496","name":"code-line","data":{},"nodes":[{"type":"text","id":"lTd8-1663834790495","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"0YIr-1663834790498","name":"code-line","data":{},"nodes":[{"type":"text","id":"UXeU-1663834790497","leaves":[{"text":" return tab;\r","marks":[]}]}]},{"type":"block","id":"85ln-1663834790500","name":"code-line","data":{},"nodes":[{"type":"text","id":"NRjA-1663834790499","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"M024-1663834790502","name":"code-line","data":{},"nodes":[{"type":"text","id":"pQU8-1663834790501","leaves":[{"text":"","marks":[]}]}]},{"type":"block","id":"qlsT-1663834784982","name":"code-line","data":{},"nodes":[{"type":"text","id":"5ud3-1663834784981","leaves":[{"text":"","marks":[]}]}]},{"type":"block","id":"Y2GN-1663834784984","name":"code-line","data":{},"nodes":[{"type":"text","id":"rO1v-1663834784983","leaves":[{"text":"","marks":[]}]}]}],"state":{"language":"php"}},{"type":"block","id":"F6Tj-1663834784988","name":"heading","data":{"version":1,"level":"h2"},"nodes":[{"type":"text","id":"XzgM-1663834784987","leaves":[{"text":"addCount() ,计算成员数量","marks":[]}]}],"state":{}},{"type":"block","id":"AztV-1663834805634","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"dtZ8-1663834805633","leaves":[{"text":"问题","marks":[{"type":"bold"}]},{"text":":如果每一个线程的更新都去修改baseCount,当竞争比较小的时候问题不大,但是当非常频繁就会导致同一时候只有一个线程能更新成功,其它线程需要自旋等待机会,如果将baseCount拆成一个个cell也就是CounterCell[],每个线程绑定一个cell单元进行自身size的添加,那么就可以分散热点。","marks":[]}]}],"state":{}},{"type":"block","id":"ZriR-1663834805636","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"Bolm-1663834805635","leaves":[{"text":"作用","marks":[{"type":"bold"}]},{"text":":和LongAdder思路一样,分散热点,提高性能,同时增加查询size时候的性能问题,只有当竞争强度上升才会启用","marks":[]}]}],"state":{}},{"type":"block","id":"ZjLt-1663834805638","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"Vo8b-1663834805637","leaves":[{"text":"","marks":[]}]}],"state":{}},{"type":"block","id":"NI49-1663834820373","name":"image","data":{"version":1,"url":"https://note.youdao.com/yws/public/resource/86b63a4248380f0bf60307d27b7553e4/xmlnote/WEBRESOURCEa7a7ca5b649022f395380c8ead214c70/737","width":698,"height":424},"nodes":[],"state":{"renderSource":"https://note.youdao.com/yws/public/resource/86b63a4248380f0bf60307d27b7553e4/xmlnote/WEBRESOURCEa7a7ca5b649022f395380c8ead214c70/737","initialSize":{"width":698,"height":424},"loading":false}},{"type":"block","id":"vtr5-1663834829805","name":"paragraph","data":{},"nodes":[{"type":"text","id":"5hng-1663834829806","leaves":[{"text":"","marks":[]}]}],"state":{}},{"type":"block","id":"vFOe-1663834829804","name":"code","data":{"wrap":false,"language":"","theme":"default"},"nodes":[{"type":"block","id":"6T7J-1663834829803","name":"code-line","data":{},"nodes":[{"type":"text","id":"DlEg-1663834820374","leaves":[{"text":" private final void addCount(long x, int check) {\r","marks":[]}]}]},{"type":"block","id":"u25h-1663834830542","name":"code-line","data":{},"nodes":[{"type":"text","id":"378e-1663834830541","leaves":[{"text":" CounterCell[] as; long b, s;\r","marks":[]}]}]},{"type":"block","id":"vVqI-1663834830544","name":"code-line","data":{},"nodes":[{"type":"text","id":"vmLo-1663834830543","leaves":[{"text":" //统计单元不为空or数量增加失败\r","marks":[]}]}]},{"type":"block","id":"gRnx-1663834830546","name":"code-line","data":{},"nodes":[{"type":"text","id":"zNly-1663834830545","leaves":[{"text":" if ((as = counterCells) != null ||\r","marks":[]}]}]},{"type":"block","id":"yb3Z-1663834830548","name":"code-line","data":{},"nodes":[{"type":"text","id":"8miO-1663834830547","leaves":[{"text":" !U.compareAndSwapLong(this, BASECOUNT, b = baseCount, s = b + x)) {\r","marks":[]}]}]},{"type":"block","id":"OyZB-1663834830550","name":"code-line","data":{},"nodes":[{"type":"text","id":"2eRu-1663834830549","leaves":[{"text":" CounterCell a; long v; int m;\r","marks":[]}]}]},{"type":"block","id":"9FP8-1663834830552","name":"code-line","data":{},"nodes":[{"type":"text","id":"vA2a-1663834830551","leaves":[{"text":" boolean uncontended = true;\r","marks":[]}]}]},{"type":"block","id":"MK08-1663834830554","name":"code-line","data":{},"nodes":[{"type":"text","id":"zA68-1663834830553","leaves":[{"text":" if (as == null || (m = as.length - 1) < 0 ||\r","marks":[]}]}]},{"type":"block","id":"Ev5t-1663834830556","name":"code-line","data":{},"nodes":[{"type":"text","id":"YoRw-1663834830555","leaves":[{"text":" (a = as[ThreadLocalRandom.getProbe() & m]) == null ||\r","marks":[]}]}]},{"type":"block","id":"MADv-1663834830558","name":"code-line","data":{},"nodes":[{"type":"text","id":"2D3I-1663834830557","leaves":[{"text":" !(uncontended =\r","marks":[]}]}]},{"type":"block","id":"jFKs-1663834830560","name":"code-line","data":{},"nodes":[{"type":"text","id":"pHVp-1663834830559","leaves":[{"text":" U.compareAndSwapLong(a, CELLVALUE, v = a.value, v + x))) {\r","marks":[]}]}]},{"type":"block","id":"CAYb-1663834830562","name":"code-line","data":{},"nodes":[{"type":"text","id":"NJsN-1663834830561","leaves":[{"text":" //创建cells或者进行数量增加\r","marks":[]}]}]},{"type":"block","id":"K7AA-1663834830564","name":"code-line","data":{},"nodes":[{"type":"text","id":"ySe1-1663834830563","leaves":[{"text":" fullAddCount(x, uncontended);\r","marks":[]}]}]},{"type":"block","id":"mYm1-1663834830566","name":"code-line","data":{},"nodes":[{"type":"text","id":"H0pP-1663834830565","leaves":[{"text":" return;\r","marks":[]}]}]},{"type":"block","id":"XOLW-1663834830568","name":"code-line","data":{},"nodes":[{"type":"text","id":"XRgp-1663834830567","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"NGTL-1663834830570","name":"code-line","data":{},"nodes":[{"type":"text","id":"lJSp-1663834830569","leaves":[{"text":" if (check <= 1)\r","marks":[]}]}]},{"type":"block","id":"qNiS-1663834830572","name":"code-line","data":{},"nodes":[{"type":"text","id":"UwL1-1663834830571","leaves":[{"text":" return;\r","marks":[]}]}]},{"type":"block","id":"yhgS-1663834830574","name":"code-line","data":{},"nodes":[{"type":"text","id":"5PjZ-1663834830573","leaves":[{"text":" s = sumCount();\r","marks":[]}]}]},{"type":"block","id":"2k9C-1663834830576","name":"code-line","data":{},"nodes":[{"type":"text","id":"hGYo-1663834830575","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"zQ39-1663834830578","name":"code-line","data":{},"nodes":[{"type":"text","id":"YWGh-1663834830577","leaves":[{"text":" //检查是否需要扩容\r","marks":[]}]}]},{"type":"block","id":"tuVE-1663834830580","name":"code-line","data":{},"nodes":[{"type":"text","id":"0zkF-1663834830579","leaves":[{"text":" if (check >= 0) {\r","marks":[]}]}]},{"type":"block","id":"zvCj-1663834830582","name":"code-line","data":{},"nodes":[{"type":"text","id":"CU3n-1663834830581","leaves":[{"text":" Node[] tab, nt; int n, sc;\r","marks":[]}]}]},{"type":"block","id":"haZb-1663834830584","name":"code-line","data":{},"nodes":[{"type":"text","id":"JH7t-1663834830583","leaves":[{"text":" while (s >= (long)(sc = sizeCtl) && (tab = table) != null &&\r","marks":[]}]}]},{"type":"block","id":"FJMG-1663834830586","name":"code-line","data":{},"nodes":[{"type":"text","id":"xFoB-1663834830585","leaves":[{"text":" (n = tab.length) < MAXIMUM_CAPACITY) {\r","marks":[]}]}]},{"type":"block","id":"J5mc-1663834830588","name":"code-line","data":{},"nodes":[{"type":"text","id":"p27R-1663834830587","leaves":[{"text":" int rs = resizeStamp(n);\r","marks":[]}]}]},{"type":"block","id":"HE7z-1663834830590","name":"code-line","data":{},"nodes":[{"type":"text","id":"fS8t-1663834830589","leaves":[{"text":" if (sc < 0) {\r","marks":[]}]}]},{"type":"block","id":"tcBW-1663834830593","name":"code-line","data":{},"nodes":[{"type":"text","id":"FGVT-1663834830591","leaves":[{"text":" if ((sc >>> RESIZE_STAMP_SHIFT) != rs || sc == rs + 1 ||\r","marks":[]}]}]},{"type":"block","id":"WU1X-1663834830595","name":"code-line","data":{},"nodes":[{"type":"text","id":"id5j-1663834830594","leaves":[{"text":" sc == rs + MAX_RESIZERS || (nt = nextTable) == null ||\r","marks":[]}]}]},{"type":"block","id":"fnVm-1663834830597","name":"code-line","data":{},"nodes":[{"type":"text","id":"IlXJ-1663834830596","leaves":[{"text":" transferIndex <= 0)\r","marks":[]}]}]},{"type":"block","id":"f8TA-1663834830599","name":"code-line","data":{},"nodes":[{"type":"text","id":"Gbt5-1663834830598","leaves":[{"text":" break;\r","marks":[]}]}]},{"type":"block","id":"C7PW-1663834830601","name":"code-line","data":{},"nodes":[{"type":"text","id":"qV8y-1663834830600","leaves":[{"text":" if (U.compareAndSwapInt(this, SIZECTL, sc, sc + 1))\r","marks":[]}]}]},{"type":"block","id":"PBPb-1663834830603","name":"code-line","data":{},"nodes":[{"type":"text","id":"hA5U-1663834830602","leaves":[{"text":" transfer(tab, nt);\r","marks":[]}]}]},{"type":"block","id":"yU2v-1663834830605","name":"code-line","data":{},"nodes":[{"type":"text","id":"QUgg-1663834830604","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"mP98-1663834830607","name":"code-line","data":{},"nodes":[{"type":"text","id":"1M3z-1663834830606","leaves":[{"text":" else if (U.compareAndSwapInt(this, SIZECTL, sc,\r","marks":[]}]}]},{"type":"block","id":"qcho-1663834830609","name":"code-line","data":{},"nodes":[{"type":"text","id":"WuRD-1663834830608","leaves":[{"text":" (rs << RESIZE_STAMP_SHIFT) + 2))\r","marks":[]}]}]},{"type":"block","id":"ZP9K-1663834830611","name":"code-line","data":{},"nodes":[{"type":"text","id":"FvMr-1663834830610","leaves":[{"text":" transfer(tab, null);\r","marks":[]}]}]},{"type":"block","id":"WnxF-1663834830613","name":"code-line","data":{},"nodes":[{"type":"text","id":"bIRW-1663834830612","leaves":[{"text":" s = sumCount();\r","marks":[]}]}]},{"type":"block","id":"DGWF-1663834830615","name":"code-line","data":{},"nodes":[{"type":"text","id":"fKOt-1663834830614","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"PoG1-1663834830617","name":"code-line","data":{},"nodes":[{"type":"text","id":"irEy-1663834830616","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"KpDw-1663834830619","name":"code-line","data":{},"nodes":[{"type":"text","id":"74ZK-1663834830618","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"ynPJ-1663834830621","name":"code-line","data":{},"nodes":[{"type":"text","id":"VIBy-1663834830620","leaves":[{"text":"","marks":[]}]}]}],"state":{"language":"csharp"}},{"type":"block","id":"axNg-1663834829807","name":"heading","data":{"version":1,"level":"h3"},"nodes":[{"type":"text","id":"pnRz-1663834829808","leaves":[{"text":"transfer(),进行扩容","marks":[]}]}],"state":{}},{"type":"block","id":"8RYC-1663834838930","name":"code","data":{"version":1,"language":"","theme":"default"},"nodes":[{"type":"block","id":"pHgq-1663834838923","name":"code-line","data":{},"nodes":[{"type":"text","id":"bok1-1663834838922","leaves":[{"text":" private final void transfer(Node[] tab, Node[] nextTab) {\r","marks":[]}]}]},{"type":"block","id":"qXFD-1663834846276","name":"code-line","data":{},"nodes":[{"type":"text","id":"XPcl-1663834846275","leaves":[{"text":" int n = tab.length, stride;\r","marks":[]}]}]},{"type":"block","id":"fZRW-1663834846278","name":"code-line","data":{},"nodes":[{"type":"text","id":"CKrG-1663834846277","leaves":[{"text":" //【第一步】\r","marks":[]}]}]},{"type":"block","id":"1Gq6-1663834846280","name":"code-line","data":{},"nodes":[{"type":"text","id":"rfFH-1663834846279","leaves":[{"text":" //决定当前线程在需要处理的槽位充足下,分配到的槽位数\r","marks":[]}]}]},{"type":"block","id":"7SPQ-1663834846283","name":"code-line","data":{},"nodes":[{"type":"text","id":"BvS6-1663834846281","leaves":[{"text":" if ((stride = (NCPU > 1) ? (n >>> 3) / NCPU : n) < MIN_TRANSFER_STRIDE)\r","marks":[]}]}]},{"type":"block","id":"ws3u-1663834846285","name":"code-line","data":{},"nodes":[{"type":"text","id":"rC9F-1663834846284","leaves":[{"text":" stride = MIN_TRANSFER_STRIDE; // subdivide range\r","marks":[]}]}]},{"type":"block","id":"jT30-1663834846287","name":"code-line","data":{},"nodes":[{"type":"text","id":"kuxB-1663834846286","leaves":[{"text":" //新容器为空则创建容器 \r","marks":[]}]}]},{"type":"block","id":"Mjok-1663834846289","name":"code-line","data":{},"nodes":[{"type":"text","id":"G9BT-1663834846288","leaves":[{"text":" if (nextTab == null) { // initiating\r","marks":[]}]}]},{"type":"block","id":"Xyl9-1663834846291","name":"code-line","data":{},"nodes":[{"type":"text","id":"fIUg-1663834846290","leaves":[{"text":" try {\r","marks":[]}]}]},{"type":"block","id":"RNtE-1663834846293","name":"code-line","data":{},"nodes":[{"type":"text","id":"3LvY-1663834846292","leaves":[{"text":" //多出一个赋值操作,尝试处理内存溢出?不明白原理\r","marks":[]}]}]},{"type":"block","id":"ecM0-1663834846295","name":"code-line","data":{},"nodes":[{"type":"text","id":"wDS3-1663834846294","leaves":[{"text":" @SuppressWarnings(\"unchecked\")\r","marks":[]}]}]},{"type":"block","id":"pJf4-1663834846297","name":"code-line","data":{},"nodes":[{"type":"text","id":"UUT2-1663834846296","leaves":[{"text":" Node[] nt = (Node[])new Node[n << 1];\r","marks":[]}]}]},{"type":"block","id":"KwBB-1663834846299","name":"code-line","data":{},"nodes":[{"type":"text","id":"KqDQ-1663834846298","leaves":[{"text":" nextTab = nt;\r","marks":[]}]}]},{"type":"block","id":"L8fG-1663834846301","name":"code-line","data":{},"nodes":[{"type":"text","id":"Bb1H-1663834846300","leaves":[{"text":" } catch (Throwable ex) { // try to cope with OOME\r","marks":[]}]}]},{"type":"block","id":"hmpY-1663834846303","name":"code-line","data":{},"nodes":[{"type":"text","id":"lx2g-1663834846302","leaves":[{"text":" sizeCtl = Integer.MAX_VALUE;\r","marks":[]}]}]},{"type":"block","id":"YkdX-1663834846305","name":"code-line","data":{},"nodes":[{"type":"text","id":"LuaG-1663834846304","leaves":[{"text":" return;\r","marks":[]}]}]},{"type":"block","id":"MHIH-1663834846307","name":"code-line","data":{},"nodes":[{"type":"text","id":"wcw6-1663834846306","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"XtzI-1663834846309","name":"code-line","data":{},"nodes":[{"type":"text","id":"LNHt-1663834846308","leaves":[{"text":" nextTable = nextTab;\r","marks":[]}]}]},{"type":"block","id":"PaTC-1663834846311","name":"code-line","data":{},"nodes":[{"type":"text","id":"g37n-1663834846310","leaves":[{"text":" //转移索引数设置为当前容器容量\r","marks":[]}]}]},{"type":"block","id":"lBUt-1663834846313","name":"code-line","data":{},"nodes":[{"type":"text","id":"6SA3-1663834846312","leaves":[{"text":" transferIndex = n;\r","marks":[]}]}]},{"type":"block","id":"IfhM-1663834846315","name":"code-line","data":{},"nodes":[{"type":"text","id":"63GS-1663834846314","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"a3mX-1663834846317","name":"code-line","data":{},"nodes":[{"type":"text","id":"o4le-1663834846316","leaves":[{"text":" //将下个容器的转移搜索引数设置为新容器容量\r","marks":[]}]}]},{"type":"block","id":"TnzC-1663834846319","name":"code-line","data":{},"nodes":[{"type":"text","id":"ioSo-1663834846318","leaves":[{"text":" int nextn = nextTab.length;\r","marks":[]}]}]},{"type":"block","id":"wcPJ-1663834846321","name":"code-line","data":{},"nodes":[{"type":"text","id":"CrJy-1663834846320","leaves":[{"text":" //创建ForwardingNode容器并放入新容器\r","marks":[]}]}]},{"type":"block","id":"s4zo-1663834846323","name":"code-line","data":{},"nodes":[{"type":"text","id":"Q4Zn-1663834846322","leaves":[{"text":" ForwardingNode fwd = new ForwardingNode(nextTab);\r","marks":[]}]}]},{"type":"block","id":"RwEV-1663834846325","name":"code-line","data":{},"nodes":[{"type":"text","id":"1Jmm-1663834846324","leaves":[{"text":" boolean advance = true;\r","marks":[]}]}]},{"type":"block","id":"iJ8t-1663834846327","name":"code-line","data":{},"nodes":[{"type":"text","id":"Ylqx-1663834846326","leaves":[{"text":" boolean finishing = false; // to ensure sweep before committing nextTab\r","marks":[]}]}]},{"type":"block","id":"geiP-1663834846329","name":"code-line","data":{},"nodes":[{"type":"text","id":"U9M1-1663834846328","leaves":[{"text":" for (int i = 0, bound = 0;;) {\r","marks":[]}]}]},{"type":"block","id":"bxru-1663834846331","name":"code-line","data":{},"nodes":[{"type":"text","id":"JHzG-1663834846330","leaves":[{"text":" Node f; int fh;\r","marks":[]}]}]},{"type":"block","id":"whaf-1663834846333","name":"code-line","data":{},"nodes":[{"type":"text","id":"4wZw-1663834846332","leaves":[{"text":" //【第二步,划分槽位,帮助推进】\r","marks":[]}]}]},{"type":"block","id":"rmpl-1663834846335","name":"code-line","data":{},"nodes":[{"type":"text","id":"sPkn-1663834846334","leaves":[{"text":" //选择当前线程进行transfer的槽位,从最后一个槽位向前\r","marks":[]}]}]},{"type":"block","id":"hDSX-1663834846337","name":"code-line","data":{},"nodes":[{"type":"text","id":"PRV2-1663834846336","leaves":[{"text":" while (advance) {\r","marks":[]}]}]},{"type":"block","id":"dhFb-1663834846339","name":"code-line","data":{},"nodes":[{"type":"text","id":"Ff5s-1663834846338","leaves":[{"text":" int nextIndex, nextBound;\r","marks":[]}]}]},{"type":"block","id":"Hslk-1663834846341","name":"code-line","data":{},"nodes":[{"type":"text","id":"gleG-1663834846340","leaves":[{"text":" //向前推进一个槽位,或者已经完成了\r","marks":[]}]}]},{"type":"block","id":"Hrhu-1663834846343","name":"code-line","data":{},"nodes":[{"type":"text","id":"v8vH-1663834846342","leaves":[{"text":" if (--i >= bound || finishing)\r","marks":[]}]}]},{"type":"block","id":"aDR8-1663834846345","name":"code-line","data":{},"nodes":[{"type":"text","id":"Y3UO-1663834846344","leaves":[{"text":" advance = false;\r","marks":[]}]}]},{"type":"block","id":"WIek-1663834846347","name":"code-line","data":{},"nodes":[{"type":"text","id":"3TP9-1663834846346","leaves":[{"text":" //槽位被其它线程选择完了 \r","marks":[]}]}]},{"type":"block","id":"dc0j-1663834846349","name":"code-line","data":{},"nodes":[{"type":"text","id":"wLV2-1663834846348","leaves":[{"text":" else if ((nextIndex = transferIndex) <= 0) {\r","marks":[]}]}]},{"type":"block","id":"Hh2E-1663834846352","name":"code-line","data":{},"nodes":[{"type":"text","id":"QQfK-1663834846351","leaves":[{"text":" i = -1;\r","marks":[]}]}]},{"type":"block","id":"uimL-1663834846354","name":"code-line","data":{},"nodes":[{"type":"text","id":"oN5v-1663834846353","leaves":[{"text":" advance = false;\r","marks":[]}]}]},{"type":"block","id":"0ayP-1663834846356","name":"code-line","data":{},"nodes":[{"type":"text","id":"zoHz-1663834846355","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"xHaJ-1663834846358","name":"code-line","data":{},"nodes":[{"type":"text","id":"Bo62-1663834846357","leaves":[{"text":" //尝试获取槽位的操作权\r","marks":[]}]}]},{"type":"block","id":"HBIQ-1663834846360","name":"code-line","data":{},"nodes":[{"type":"text","id":"4hmd-1663834846359","leaves":[{"text":" else if (U.compareAndSwapInt\r","marks":[]}]}]},{"type":"block","id":"Uj4y-1663834846362","name":"code-line","data":{},"nodes":[{"type":"text","id":"9D9S-1663834846361","leaves":[{"text":" (this, TRANSFERINDEX, nextIndex,\r","marks":[]}]}]},{"type":"block","id":"wZwg-1663834846364","name":"code-line","data":{},"nodes":[{"type":"text","id":"GHR1-1663834846363","leaves":[{"text":" nextBound = (nextIndex > stride ?\r","marks":[]}]}]},{"type":"block","id":"3b2i-1663834846366","name":"code-line","data":{},"nodes":[{"type":"text","id":"MAv6-1663834846365","leaves":[{"text":" nextIndex - stride : 0))) {\r","marks":[]}]}]},{"type":"block","id":"yf0q-1663834846368","name":"code-line","data":{},"nodes":[{"type":"text","id":"Rwe2-1663834846367","leaves":[{"text":" //槽位下限 \r","marks":[]}]}]},{"type":"block","id":"1TE7-1663834846370","name":"code-line","data":{},"nodes":[{"type":"text","id":"kWrH-1663834846369","leaves":[{"text":" bound = nextBound;\r","marks":[]}]}]},{"type":"block","id":"QDfQ-1663834846372","name":"code-line","data":{},"nodes":[{"type":"text","id":"nnmB-1663834846371","leaves":[{"text":" //当前选中进行处理的槽位\r","marks":[]}]}]},{"type":"block","id":"Jx67-1663834846374","name":"code-line","data":{},"nodes":[{"type":"text","id":"wNDm-1663834846373","leaves":[{"text":" i = nextIndex - 1;\r","marks":[]}]}]},{"type":"block","id":"FCMs-1663834846376","name":"code-line","data":{},"nodes":[{"type":"text","id":"IkbV-1663834846375","leaves":[{"text":" advance = false;\r","marks":[]}]}]},{"type":"block","id":"B4Ay-1663834846378","name":"code-line","data":{},"nodes":[{"type":"text","id":"xcVP-1663834846377","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"QAgD-1663834846380","name":"code-line","data":{},"nodes":[{"type":"text","id":"QvAB-1663834846379","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"R5bA-1663834846382","name":"code-line","data":{},"nodes":[{"type":"text","id":"jU4J-1663834846381","leaves":[{"text":" //被选择完毕,选中槽位大于当前容器容量,选中槽位+当前容器容量大于新容器容量\r","marks":[]}]}]},{"type":"block","id":"vSYX-1663834846384","name":"code-line","data":{},"nodes":[{"type":"text","id":"oqCX-1663834846383","leaves":[{"text":" //【第三步,设置结束条件,变更地址】\r","marks":[]}]}]},{"type":"block","id":"2PHQ-1663834846386","name":"code-line","data":{},"nodes":[{"type":"text","id":"q1aT-1663834846385","leaves":[{"text":" if (i < 0 || i >= n || i + n >= nextn) {\r","marks":[]}]}]},{"type":"block","id":"FHIF-1663834846388","name":"code-line","data":{},"nodes":[{"type":"text","id":"Viub-1663834846387","leaves":[{"text":" int sc;\r","marks":[]}]}]},{"type":"block","id":"80Tp-1663834846390","name":"code-line","data":{},"nodes":[{"type":"text","id":"0Wem-1663834846389","leaves":[{"text":" //扩容完毕\r","marks":[]}]}]},{"type":"block","id":"xNiM-1663834846392","name":"code-line","data":{},"nodes":[{"type":"text","id":"mu1H-1663834846391","leaves":[{"text":" if (finishing) {\r","marks":[]}]}]},{"type":"block","id":"eTEZ-1663834846394","name":"code-line","data":{},"nodes":[{"type":"text","id":"hUOO-1663834846393","leaves":[{"text":" //清除扩容时创建的临时表\r","marks":[]}]}]},{"type":"block","id":"066g-1663834846396","name":"code-line","data":{},"nodes":[{"type":"text","id":"g1Ig-1663834846395","leaves":[{"text":" nextTable = null;\r","marks":[]}]}]},{"type":"block","id":"3X7h-1663834846398","name":"code-line","data":{},"nodes":[{"type":"text","id":"Sb65-1663834846397","leaves":[{"text":" //将当前表指向临时表\r","marks":[]}]}]},{"type":"block","id":"nkqL-1663834846400","name":"code-line","data":{},"nodes":[{"type":"text","id":"TTqo-1663834846399","leaves":[{"text":" table = nextTab;\r","marks":[]}]}]},{"type":"block","id":"B0dv-1663834846402","name":"code-line","data":{},"nodes":[{"type":"text","id":"9Jiu-1663834846401","leaves":[{"text":" //设置下次扩容的临界点为 0.75*扩容容量\r","marks":[]}]}]},{"type":"block","id":"jEgS-1663834846404","name":"code-line","data":{},"nodes":[{"type":"text","id":"auAr-1663834846403","leaves":[{"text":" sizeCtl = (n << 1) - (n >>> 1);\r","marks":[]}]}]},{"type":"block","id":"FMfQ-1663834846406","name":"code-line","data":{},"nodes":[{"type":"text","id":"1Ah4-1663834846405","leaves":[{"text":" return;\r","marks":[]}]}]},{"type":"block","id":"Ab6B-1663834846408","name":"code-line","data":{},"nodes":[{"type":"text","id":"qnNK-1663834846407","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"PqxN-1663834846411","name":"code-line","data":{},"nodes":[{"type":"text","id":"AYFr-1663834846410","leaves":[{"text":" //将扩容标识中的线程标识减一\r","marks":[]}]}]},{"type":"block","id":"Or0z-1663834846413","name":"code-line","data":{},"nodes":[{"type":"text","id":"hOpk-1663834846412","leaves":[{"text":" if (U.compareAndSwapInt(this, SIZECTL, sc = sizeCtl, sc - 1)) {\r","marks":[]}]}]},{"type":"block","id":"oiwK-1663834846415","name":"code-line","data":{},"nodes":[{"type":"text","id":"WUGm-1663834846414","leaves":[{"text":" //存在其它线程进行扩容处理,则当前线程处理完自己的槽位后直接退出\r","marks":[]}]}]},{"type":"block","id":"C2WO-1663834846417","name":"code-line","data":{},"nodes":[{"type":"text","id":"m13T-1663834846416","leaves":[{"text":" if ((sc - 2) != resizeStamp(n) << RESIZE_STAMP_SHIFT)\r","marks":[]}]}]},{"type":"block","id":"dT7o-1663834846419","name":"code-line","data":{},"nodes":[{"type":"text","id":"7tKB-1663834846418","leaves":[{"text":" return;\r","marks":[]}]}]},{"type":"block","id":"tOR9-1663834846421","name":"code-line","data":{},"nodes":[{"type":"text","id":"16y4-1663834846420","leaves":[{"text":" //不存在其它线程处理,说明自己是唯一处理线程 \r","marks":[]}]}]},{"type":"block","id":"yDVM-1663834846423","name":"code-line","data":{},"nodes":[{"type":"text","id":"ZvOc-1663834846422","leaves":[{"text":" finishing = advance = true;\r","marks":[]}]}]},{"type":"block","id":"No9i-1663834846425","name":"code-line","data":{},"nodes":[{"type":"text","id":"Z0Nn-1663834846424","leaves":[{"text":" //将i重置,在看下还有没有transferIndex\r","marks":[]}]}]},{"type":"block","id":"93IY-1663834846427","name":"code-line","data":{},"nodes":[{"type":"text","id":"BELu-1663834846426","leaves":[{"text":" //如果已经是唯一处理线程并且满足前置条件,为何需要检查下?\r","marks":[]}]}]},{"type":"block","id":"HVg0-1663834846429","name":"code-line","data":{},"nodes":[{"type":"text","id":"J567-1663834846428","leaves":[{"text":" i = n; // recheck before commit\r","marks":[]}]}]},{"type":"block","id":"1Ii7-1663834846431","name":"code-line","data":{},"nodes":[{"type":"text","id":"l1GS-1663834846430","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"f7so-1663834846433","name":"code-line","data":{},"nodes":[{"type":"text","id":"6noV-1663834846432","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"XUSD-1663834846435","name":"code-line","data":{},"nodes":[{"type":"text","id":"BLLJ-1663834846434","leaves":[{"text":" //【第四步,处理槽位】\r","marks":[]}]}]},{"type":"block","id":"Sxha-1663834846437","name":"code-line","data":{},"nodes":[{"type":"text","id":"kvrX-1663834846436","leaves":[{"text":" //如果当前槽中没有成员,用forwarding节点占位\r","marks":[]}]}]},{"type":"block","id":"XOzE-1663834846439","name":"code-line","data":{},"nodes":[{"type":"text","id":"EDHf-1663834846438","leaves":[{"text":" else if ((f = tabAt(tab, i)) == null)\r","marks":[]}]}]},{"type":"block","id":"HmUZ-1663834846441","name":"code-line","data":{},"nodes":[{"type":"text","id":"MsqX-1663834846440","leaves":[{"text":" advance = casTabAt(tab, i, null, fwd);\r","marks":[]}]}]},{"type":"block","id":"xFea-1663834846443","name":"code-line","data":{},"nodes":[{"type":"text","id":"Tsnc-1663834846442","leaves":[{"text":" //如果当前槽中成员为forwarding节点,代表已经被处理过了 \r","marks":[]}]}]},{"type":"block","id":"VEmG-1663834846445","name":"code-line","data":{},"nodes":[{"type":"text","id":"HzNR-1663834846444","leaves":[{"text":" else if ((fh = f.hash) == MOVED)\r","marks":[]}]}]},{"type":"block","id":"3GzP-1663834846447","name":"code-line","data":{},"nodes":[{"type":"text","id":"pCXC-1663834846446","leaves":[{"text":" //处理下一个槽\r","marks":[]}]}]},{"type":"block","id":"pPXi-1663834846449","name":"code-line","data":{},"nodes":[{"type":"text","id":"oCbT-1663834846448","leaves":[{"text":" advance = true; // already processed\r","marks":[]}]}]},{"type":"block","id":"39VR-1663834846451","name":"code-line","data":{},"nodes":[{"type":"text","id":"76CR-1663834846450","leaves":[{"text":" else {\r","marks":[]}]}]},{"type":"block","id":"GUsD-1663834846453","name":"code-line","data":{},"nodes":[{"type":"text","id":"IMVf-1663834846452","leaves":[{"text":" //锁住槽位\r","marks":[]}]}]},{"type":"block","id":"99vj-1663834846455","name":"code-line","data":{},"nodes":[{"type":"text","id":"B6vX-1663834846454","leaves":[{"text":" synchronized (f) {\r","marks":[]}]}]},{"type":"block","id":"MK3h-1663834846457","name":"code-line","data":{},"nodes":[{"type":"text","id":"Km3Y-1663834846456","leaves":[{"text":" //double check\r","marks":[]}]}]},{"type":"block","id":"aedG-1663834846459","name":"code-line","data":{},"nodes":[{"type":"text","id":"yxSS-1663834846458","leaves":[{"text":" if (tabAt(tab, i) == f) {\r","marks":[]}]}]},{"type":"block","id":"yGHC-1663834846461","name":"code-line","data":{},"nodes":[{"type":"text","id":"N1CX-1663834846460","leaves":[{"text":" Node ln, hn;\r","marks":[]}]}]},{"type":"block","id":"0mpK-1663834846463","name":"code-line","data":{},"nodes":[{"type":"text","id":"eWKn-1663834846462","leaves":[{"text":" if (fh >= 0) {\r","marks":[]}]}]},{"type":"block","id":"CJQC-1663834846465","name":"code-line","data":{},"nodes":[{"type":"text","id":"tOTC-1663834846464","leaves":[{"text":" //计算当前成员最高位\r","marks":[]}]}]},{"type":"block","id":"5FcA-1663834846467","name":"code-line","data":{},"nodes":[{"type":"text","id":"KTjd-1663834846466","leaves":[{"text":" //runBit是0 or 1\r","marks":[]}]}]},{"type":"block","id":"PBcQ-1663834846469","name":"code-line","data":{},"nodes":[{"type":"text","id":"dttg-1663834846468","leaves":[{"text":" int runBit = fh & n;\r","marks":[]}]}]},{"type":"block","id":"b2W5-1663834846471","name":"code-line","data":{},"nodes":[{"type":"text","id":"LkD9-1663834846470","leaves":[{"text":" Node lastRun = f;\r","marks":[]}]}]},{"type":"block","id":"hyoD-1663834846473","name":"code-line","data":{},"nodes":[{"type":"text","id":"WzyV-1663834846472","leaves":[{"text":" for (Node p = f.next; p != null; p = p.next) {\r","marks":[]}]}]},{"type":"block","id":"P3CW-1663834846475","name":"code-line","data":{},"nodes":[{"type":"text","id":"b70B-1663834846474","leaves":[{"text":" int b = p.hash & n;\r","marks":[]}]}]},{"type":"block","id":"lY1K-1663834846477","name":"code-line","data":{},"nodes":[{"type":"text","id":"4tc2-1663834846476","leaves":[{"text":" //查找最后重复的链,获得开始位置p,和重复的高位值runBit\r","marks":[]}]}]},{"type":"block","id":"1W3E-1663834846479","name":"code-line","data":{},"nodes":[{"type":"text","id":"nlRX-1663834846478","leaves":[{"text":" if (b != runBit) {\r","marks":[]}]}]},{"type":"block","id":"FhT4-1663834846482","name":"code-line","data":{},"nodes":[{"type":"text","id":"2kfF-1663834846480","leaves":[{"text":" runBit = b;\r","marks":[]}]}]},{"type":"block","id":"0Chj-1663834846484","name":"code-line","data":{},"nodes":[{"type":"text","id":"6M8F-1663834846483","leaves":[{"text":" lastRun = p;\r","marks":[]}]}]},{"type":"block","id":"HAK8-1663834846486","name":"code-line","data":{},"nodes":[{"type":"text","id":"qon1-1663834846485","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"f8hT-1663834846488","name":"code-line","data":{},"nodes":[{"type":"text","id":"NERm-1663834846487","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"y5if-1663834846490","name":"code-line","data":{},"nodes":[{"type":"text","id":"WK0I-1663834846489","leaves":[{"text":" //如果从p开始后面高位全是0,那么就不需要移动到新槽中\r","marks":[]}]}]},{"type":"block","id":"ZYzP-1663834846492","name":"code-line","data":{},"nodes":[{"type":"text","id":"TWop-1663834846491","leaves":[{"text":" if (runBit == 0) {\r","marks":[]}]}]},{"type":"block","id":"wUtL-1663834846494","name":"code-line","data":{},"nodes":[{"type":"text","id":"BfgL-1663834846493","leaves":[{"text":" ln = lastRun;\r","marks":[]}]}]},{"type":"block","id":"qdCl-1663834846496","name":"code-line","data":{},"nodes":[{"type":"text","id":"ZHUG-1663834846495","leaves":[{"text":" hn = null;\r","marks":[]}]}]},{"type":"block","id":"1ESU-1663834846498","name":"code-line","data":{},"nodes":[{"type":"text","id":"k6iT-1663834846497","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"Mdlx-1663834846500","name":"code-line","data":{},"nodes":[{"type":"text","id":"SMHf-1663834846499","leaves":[{"text":" //如果从p开始后面全是1,那么就需要移动到新槽中\r","marks":[]}]}]},{"type":"block","id":"H6rZ-1663834846502","name":"code-line","data":{},"nodes":[{"type":"text","id":"CRiZ-1663834846501","leaves":[{"text":" else {\r","marks":[]}]}]},{"type":"block","id":"yPI4-1663834846504","name":"code-line","data":{},"nodes":[{"type":"text","id":"a96N-1663834846503","leaves":[{"text":" hn = lastRun;\r","marks":[]}]}]},{"type":"block","id":"AWnZ-1663834846506","name":"code-line","data":{},"nodes":[{"type":"text","id":"1EFR-1663834846505","leaves":[{"text":" ln = null;\r","marks":[]}]}]},{"type":"block","id":"eMYG-1663834846508","name":"code-line","data":{},"nodes":[{"type":"text","id":"y3u1-1663834846507","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"8QRp-1663834846510","name":"code-line","data":{},"nodes":[{"type":"text","id":"4ohM-1663834846509","leaves":[{"text":" //从链的头部一直遍历到p的位置(因为p以后高位都一样)\r","marks":[]}]}]},{"type":"block","id":"e7y0-1663834846512","name":"code-line","data":{},"nodes":[{"type":"text","id":"mYpi-1663834846511","leaves":[{"text":" //为何需要提前找一部分重复?效率更高?这么处理是否有理论依据?\r","marks":[]}]}]},{"type":"block","id":"JsUO-1663834846514","name":"code-line","data":{},"nodes":[{"type":"text","id":"r4T3-1663834846513","leaves":[{"text":" for (Node p = f; p != lastRun; p = p.next) {\r","marks":[]}]}]},{"type":"block","id":"2otK-1663834846516","name":"code-line","data":{},"nodes":[{"type":"text","id":"vmYr-1663834846515","leaves":[{"text":" int ph = p.hash; K pk = p.key; V pv = p.val;\r","marks":[]}]}]},{"type":"block","id":"npzl-1663834846518","name":"code-line","data":{},"nodes":[{"type":"text","id":"wqHn-1663834846517","leaves":[{"text":" //高位为0放到旧槽位中\r","marks":[]}]}]},{"type":"block","id":"OJ5c-1663834846520","name":"code-line","data":{},"nodes":[{"type":"text","id":"PaVn-1663834846519","leaves":[{"text":" if ((ph & n) == 0)\r","marks":[]}]}]},{"type":"block","id":"RDcH-1663834846522","name":"code-line","data":{},"nodes":[{"type":"text","id":"83op-1663834846521","leaves":[{"text":" ln = new Node(ph, pk, pv, ln);\r","marks":[]}]}]},{"type":"block","id":"7323-1663834846524","name":"code-line","data":{},"nodes":[{"type":"text","id":"w1R5-1663834846523","leaves":[{"text":" //高位为1放到新槽位中\r","marks":[]}]}]},{"type":"block","id":"e6jO-1663834846526","name":"code-line","data":{},"nodes":[{"type":"text","id":"Hoc8-1663834846525","leaves":[{"text":" else\r","marks":[]}]}]},{"type":"block","id":"vmYc-1663834846528","name":"code-line","data":{},"nodes":[{"type":"text","id":"6ra8-1663834846527","leaves":[{"text":" hn = new Node(ph, pk, pv, hn);\r","marks":[]}]}]},{"type":"block","id":"QXDD-1663834846530","name":"code-line","data":{},"nodes":[{"type":"text","id":"xCCw-1663834846529","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"jeuT-1663834846532","name":"code-line","data":{},"nodes":[{"type":"text","id":"xTLI-1663834846531","leaves":[{"text":" //将ln放到新容器的旧槽位中\r","marks":[]}]}]},{"type":"block","id":"vlZT-1663834846534","name":"code-line","data":{},"nodes":[{"type":"text","id":"B5RS-1663834846533","leaves":[{"text":" setTabAt(nextTab, i, ln);\r","marks":[]}]}]},{"type":"block","id":"y1xQ-1663834846536","name":"code-line","data":{},"nodes":[{"type":"text","id":"63aG-1663834846535","leaves":[{"text":" //将hn放到新容器的新槽位中\r","marks":[]}]}]},{"type":"block","id":"5trf-1663834846538","name":"code-line","data":{},"nodes":[{"type":"text","id":"pf79-1663834846537","leaves":[{"text":" setTabAt(nextTab, i + n, hn);\r","marks":[]}]}]},{"type":"block","id":"lVx6-1663834846540","name":"code-line","data":{},"nodes":[{"type":"text","id":"9Q1M-1663834846539","leaves":[{"text":" //将老容器中的该节点设置为forwarding节点\r","marks":[]}]}]},{"type":"block","id":"f2Tv-1663834846542","name":"code-line","data":{},"nodes":[{"type":"text","id":"sAqs-1663834846541","leaves":[{"text":" setTabAt(tab, i, fwd);\r","marks":[]}]}]},{"type":"block","id":"JepV-1663834846544","name":"code-line","data":{},"nodes":[{"type":"text","id":"yH6n-1663834846543","leaves":[{"text":" //处理下一个槽位\r","marks":[]}]}]},{"type":"block","id":"aVfh-1663834846546","name":"code-line","data":{},"nodes":[{"type":"text","id":"QkNx-1663834846545","leaves":[{"text":" advance = true;\r","marks":[]}]}]},{"type":"block","id":"cva7-1663834846548","name":"code-line","data":{},"nodes":[{"type":"text","id":"tVG4-1663834846547","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"ZzjE-1663834846550","name":"code-line","data":{},"nodes":[{"type":"text","id":"uk1c-1663834846549","leaves":[{"text":" //TreeBin的hash固定为-2,红黑树的调整\r","marks":[]}]}]},{"type":"block","id":"An1Y-1663834846552","name":"code-line","data":{},"nodes":[{"type":"text","id":"kOuI-1663834846551","leaves":[{"text":" else if (f instanceof TreeBin) {\r","marks":[]}]}]},{"type":"block","id":"M4kr-1663834846554","name":"code-line","data":{},"nodes":[{"type":"text","id":"c6XK-1663834846553","leaves":[{"text":" TreeBin t = (TreeBin)f;\r","marks":[]}]}]},{"type":"block","id":"Xx2w-1663834846556","name":"code-line","data":{},"nodes":[{"type":"text","id":"yD93-1663834846555","leaves":[{"text":" TreeNode lo = null, loTail = null;\r","marks":[]}]}]},{"type":"block","id":"U5bh-1663834846558","name":"code-line","data":{},"nodes":[{"type":"text","id":"cui8-1663834846557","leaves":[{"text":" TreeNode hi = null, hiTail = null;\r","marks":[]}]}]},{"type":"block","id":"jsat-1663834846560","name":"code-line","data":{},"nodes":[{"type":"text","id":"gktz-1663834846559","leaves":[{"text":" int lc = 0, hc = 0;\r","marks":[]}]}]},{"type":"block","id":"w5Gr-1663834846562","name":"code-line","data":{},"nodes":[{"type":"text","id":"BjC3-1663834846561","leaves":[{"text":" for (Node e = t.first; e != null; e = e.next) {\r","marks":[]}]}]},{"type":"block","id":"e5dJ-1663834846564","name":"code-line","data":{},"nodes":[{"type":"text","id":"bOpa-1663834846563","leaves":[{"text":" int h = e.hash;\r","marks":[]}]}]},{"type":"block","id":"xZBK-1663834846566","name":"code-line","data":{},"nodes":[{"type":"text","id":"trGb-1663834846565","leaves":[{"text":" TreeNode p = new TreeNode\r","marks":[]}]}]},{"type":"block","id":"fmSA-1663834846568","name":"code-line","data":{},"nodes":[{"type":"text","id":"nSUV-1663834846567","leaves":[{"text":" (h, e.key, e.val, null, null);\r","marks":[]}]}]},{"type":"block","id":"wZJA-1663834846571","name":"code-line","data":{},"nodes":[{"type":"text","id":"JJky-1663834846569","leaves":[{"text":" if ((h & n) == 0) {\r","marks":[]}]}]},{"type":"block","id":"auVz-1663834846573","name":"code-line","data":{},"nodes":[{"type":"text","id":"tFYX-1663834846572","leaves":[{"text":" if ((p.prev = loTail) == null)\r","marks":[]}]}]},{"type":"block","id":"cAo4-1663834846575","name":"code-line","data":{},"nodes":[{"type":"text","id":"Uh29-1663834846574","leaves":[{"text":" lo = p;\r","marks":[]}]}]},{"type":"block","id":"LMnU-1663834846577","name":"code-line","data":{},"nodes":[{"type":"text","id":"919e-1663834846576","leaves":[{"text":" else\r","marks":[]}]}]},{"type":"block","id":"p6EB-1663834846579","name":"code-line","data":{},"nodes":[{"type":"text","id":"tAKH-1663834846578","leaves":[{"text":" loTail.next = p;\r","marks":[]}]}]},{"type":"block","id":"9faw-1663834846581","name":"code-line","data":{},"nodes":[{"type":"text","id":"nabO-1663834846580","leaves":[{"text":" loTail = p;\r","marks":[]}]}]},{"type":"block","id":"fhZE-1663834846583","name":"code-line","data":{},"nodes":[{"type":"text","id":"40LD-1663834846582","leaves":[{"text":" ++lc;\r","marks":[]}]}]},{"type":"block","id":"T4uW-1663834846585","name":"code-line","data":{},"nodes":[{"type":"text","id":"w2ws-1663834846584","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"HKV8-1663834846587","name":"code-line","data":{},"nodes":[{"type":"text","id":"ZKns-1663834846586","leaves":[{"text":" else {\r","marks":[]}]}]},{"type":"block","id":"nE5G-1663834846589","name":"code-line","data":{},"nodes":[{"type":"text","id":"aHrm-1663834846588","leaves":[{"text":" if ((p.prev = hiTail) == null)\r","marks":[]}]}]},{"type":"block","id":"r1lW-1663834846591","name":"code-line","data":{},"nodes":[{"type":"text","id":"hzMy-1663834846590","leaves":[{"text":" hi = p;\r","marks":[]}]}]},{"type":"block","id":"Wm28-1663834846593","name":"code-line","data":{},"nodes":[{"type":"text","id":"tQ75-1663834846592","leaves":[{"text":" else\r","marks":[]}]}]},{"type":"block","id":"E9kq-1663834846595","name":"code-line","data":{},"nodes":[{"type":"text","id":"tJdJ-1663834846594","leaves":[{"text":" hiTail.next = p;\r","marks":[]}]}]},{"type":"block","id":"UaX1-1663834846597","name":"code-line","data":{},"nodes":[{"type":"text","id":"mRxz-1663834846596","leaves":[{"text":" hiTail = p;\r","marks":[]}]}]},{"type":"block","id":"ASnP-1663834846599","name":"code-line","data":{},"nodes":[{"type":"text","id":"K46M-1663834846598","leaves":[{"text":" ++hc;\r","marks":[]}]}]},{"type":"block","id":"wUx6-1663834846601","name":"code-line","data":{},"nodes":[{"type":"text","id":"qygs-1663834846600","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"JpBO-1663834846603","name":"code-line","data":{},"nodes":[{"type":"text","id":"nFiA-1663834846602","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"1TVC-1663834846605","name":"code-line","data":{},"nodes":[{"type":"text","id":"iYRs-1663834846604","leaves":[{"text":" //槽位里成员少于等于6,退化为链表\r","marks":[]}]}]},{"type":"block","id":"mh6y-1663834846607","name":"code-line","data":{},"nodes":[{"type":"text","id":"gr6F-1663834846606","leaves":[{"text":" ln = (lc <= UNTREEIFY_THRESHOLD) ? untreeify(lo) :\r","marks":[]}]}]},{"type":"block","id":"qZQF-1663834846609","name":"code-line","data":{},"nodes":[{"type":"text","id":"fL5P-1663834846608","leaves":[{"text":" (hc != 0) ? new TreeBin(lo) : t;\r","marks":[]}]}]},{"type":"block","id":"YbDK-1663834846611","name":"code-line","data":{},"nodes":[{"type":"text","id":"w8CO-1663834846610","leaves":[{"text":" hn = (hc <= UNTREEIFY_THRESHOLD) ? untreeify(hi) :\r","marks":[]}]}]},{"type":"block","id":"1s3o-1663834846613","name":"code-line","data":{},"nodes":[{"type":"text","id":"Epmu-1663834846612","leaves":[{"text":" (lc != 0) ? new TreeBin(hi) : t;\r","marks":[]}]}]},{"type":"block","id":"mdeM-1663834846615","name":"code-line","data":{},"nodes":[{"type":"text","id":"ipJR-1663834846614","leaves":[{"text":" setTabAt(nextTab, i, ln);\r","marks":[]}]}]},{"type":"block","id":"5oFQ-1663834846617","name":"code-line","data":{},"nodes":[{"type":"text","id":"bI2T-1663834846616","leaves":[{"text":" setTabAt(nextTab, i + n, hn);\r","marks":[]}]}]},{"type":"block","id":"KjR0-1663834846619","name":"code-line","data":{},"nodes":[{"type":"text","id":"n969-1663834846618","leaves":[{"text":" setTabAt(tab, i, fwd);\r","marks":[]}]}]},{"type":"block","id":"Yo1k-1663834846621","name":"code-line","data":{},"nodes":[{"type":"text","id":"O3zz-1663834846620","leaves":[{"text":" advance = true;\r","marks":[]}]}]},{"type":"block","id":"oSYo-1663834846623","name":"code-line","data":{},"nodes":[{"type":"text","id":"LfJf-1663834846622","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"Y86J-1663834846625","name":"code-line","data":{},"nodes":[{"type":"text","id":"7iPA-1663834846624","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"6hOC-1663834846627","name":"code-line","data":{},"nodes":[{"type":"text","id":"SMfX-1663834846626","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"7HMW-1663834846629","name":"code-line","data":{},"nodes":[{"type":"text","id":"4cz9-1663834846628","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"xVSQ-1663834846631","name":"code-line","data":{},"nodes":[{"type":"text","id":"1qfu-1663834846630","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"UPgY-1663834846633","name":"code-line","data":{},"nodes":[{"type":"text","id":"QDtI-1663834846632","leaves":[{"text":" }\r","marks":[]}]}]},{"type":"block","id":"pSun-1663834846635","name":"code-line","data":{},"nodes":[{"type":"text","id":"TwIV-1663834846634","leaves":[{"text":"","marks":[]}]}]},{"type":"block","id":"1Wun-1663834838925","name":"code-line","data":{},"nodes":[{"type":"text","id":"nNNB-1663834838924","leaves":[{"text":"","marks":[]}]}]},{"type":"block","id":"Dphi-1663834838927","name":"code-line","data":{},"nodes":[{"type":"text","id":"Qesy-1663834838926","leaves":[{"text":"","marks":[]}]}]},{"type":"block","id":"XNir-1663834838929","name":"code-line","data":{},"nodes":[{"type":"text","id":"QXGQ-1663834838928","leaves":[{"text":"","marks":[]}]}]}],"state":{"language":"php"}},{"type":"block","id":"5xij-1663834838933","name":"paragraph","data":{},"nodes":[{"type":"text","id":"cyDe-1663834838932","leaves":[{"text":"将容器中的槽位分成多份,由后往前分割槽位,线程处理自己获取到的分段槽位(分段槽位内部连续,分段槽位间不出现交集,避免竞争提高性能...

特别声明:以上内容(如有图片或视频亦包括在内)为自媒体平台“网易号”用户上传并发布,本平台仅提供信息存储服务。

Notice: The content above (including the pictures and videos if any) is uploaded and posted by a user of NetEase Hao, which is a social media platform and only provides information storage services.

相关推荐
热点推荐
独行侠力压快船!东契奇14+6欧文低迷,哈登三分爆发,威少拼全力

独行侠力压快船!东契奇14+6欧文低迷,哈登三分爆发,威少拼全力

刺头体育
2024-04-28 12:19:38
上海婆婆“反洗房”新招:增加2个步骤,小两口离婚分不走半套房

上海婆婆“反洗房”新招:增加2个步骤,小两口离婚分不走半套房

今天不开心
2024-04-28 16:35:44
张韶涵的“渣女站姿”火了!腿缝几乎没有间距, 看得人眼睛都直了

张韶涵的“渣女站姿”火了!腿缝几乎没有间距, 看得人眼睛都直了

阿芒娱乐说
2024-04-27 12:23:34
足协看走眼了?高薪聘请的洋帅却让中国男足再次遭惨败,引发热议

足协看走眼了?高薪聘请的洋帅却让中国男足再次遭惨败,引发热议

罗掌柜体育
2024-04-28 12:56:52
不但美国震惊了日本也震惊了,就连马斯克想了三天三夜也弄不明白

不但美国震惊了日本也震惊了,就连马斯克想了三天三夜也弄不明白

穷游天下的阿等
2024-04-28 18:51:38
致创业者:“现金为王”的时代已到来

致创业者:“现金为王”的时代已到来

餐饮O2O
2024-04-27 20:59:01
何超琼闪现黄山,脚穿布鞋身背爱马仕,市委书记全程陪同引争议?

何超琼闪现黄山,脚穿布鞋身背爱马仕,市委书记全程陪同引争议?

王大健美食日常
2024-04-28 21:11:40
重庆这件事,已经不是践踏公平的问题了

重庆这件事,已经不是践踏公平的问题了

顾礼先生
2024-04-22 15:51:11
多位网友反映连接高铁WiFi时弹出“X你妈”,12306:官方无法处理

多位网友反映连接高铁WiFi时弹出“X你妈”,12306:官方无法处理

王晓爱体彩
2024-04-28 21:47:01
县委书记接受高档宴请、收受高档白酒和礼金第二天,被查了!

县委书记接受高档宴请、收受高档白酒和礼金第二天,被查了!

新京报
2024-04-28 11:40:20
河北人肉煎饼案谷宝成被执行死刑,行刑前哭着抽完2根烟

河北人肉煎饼案谷宝成被执行死刑,行刑前哭着抽完2根烟

青丝人生
2024-04-07 19:08:37
南宁市公安局原常务副局长程文科被查

南宁市公安局原常务副局长程文科被查

人民资讯
2024-04-28 16:58:22
【耶嘿侃新片01】桃乃木香奈第100个投稿!樱空桃VS伊藤舞雪!

【耶嘿侃新片01】桃乃木香奈第100个投稿!樱空桃VS伊藤舞雪!

耶嘿说业界
2024-04-28 21:57:11
状态一般 斯诺克世锦赛1/8决赛:奥沙利文第一阶段5-3领先瑞恩-戴

状态一般 斯诺克世锦赛1/8决赛:奥沙利文第一阶段5-3领先瑞恩-戴

直播吧
2024-04-28 19:40:12
妻子拒绝和丈夫过夫妻生活遭殴打,妻子哭诉:那玩意谁扛得住呀!

妻子拒绝和丈夫过夫妻生活遭殴打,妻子哭诉:那玩意谁扛得住呀!

山海音乐说
2024-04-27 02:11:14
世锦赛:世界第一四连鞭!即时世界第一连扳四局反超希金斯

世锦赛:世界第一四连鞭!即时世界第一连扳四局反超希金斯

求球不落谛
2024-04-29 05:38:20
梅西足球之光!梅西效应!2024年全美现场观众人数迈阿密站两位!

梅西足球之光!梅西效应!2024年全美现场观众人数迈阿密站两位!

元爸体育
2024-04-28 21:41:38
22分12篮板8助攻!小波特盼重返NBA打球:感谢希腊球队给机会

22分12篮板8助攻!小波特盼重返NBA打球:感谢希腊球队给机会

罗说NBA
2024-04-29 05:13:28
大降价就是好卖!奥迪A6L下跌幅度达11.6万,一个月卖了16505辆

大降价就是好卖!奥迪A6L下跌幅度达11.6万,一个月卖了16505辆

户外小阿隋
2024-04-28 21:36:32
有网友总结:在中国,想失业比考北大还要难,真正符合失业标准的少之又少!

有网友总结:在中国,想失业比考北大还要难,真正符合失业标准的少之又少!

可达鸭面面观
2024-04-26 18:55:09
2024-04-29 06:32:49
会呼吸的Coder
会呼吸的Coder
科技改变世界
466文章数 1813关注度
往期回顾 全部

科技要闻

特斯拉生死时速,马斯克西天取经

头条要闻

警方通报女子在卫生间被打:4人被行拘13日罚款1千元

头条要闻

警方通报女子在卫生间被打:4人被行拘13日罚款1千元

体育要闻

湖人的G4,尽人事得到了回报

娱乐要闻

张杰谢娜发文为何炅庆生,亲如家人!

财经要闻

上财万字报告深度解读Q1经济

汽车要闻

鸿蒙首款行政旗舰轿车 华为享界S9实车亮相车展

态度原创

时尚
本地
手机
公开课
军事航空

裤子+小猫跟,这个组合气质又好看

本地新闻

云游中国|苗族蜡染:九黎城的“潮”文化

手机要闻

OPPO Reno12系列再次被确认:物料已在准备,超大杯疑似被砍!

公开课

父亲年龄越大孩子越不聪明?

军事要闻

也门胡塞击落美军"死神"无人机 并展示残骸

无障碍浏览 进入关怀版