美文网首页
HashMap put(K, V) process

HashMap put(K, V) process

作者: 君子兰琚琚 | 来源:发表于2022-03-24 15:02 被阅读0次

    put(K, V) process of the jdk 1.8 HashMap

    1. calculate key hash value
    2. hash table is null or empty ?
      init hash table by invoke resize() that if hash table is null or empty
    3. calculate the index of key in the hash table
      1. hash conflict
        1. is want to replace value ?
          replace new value
        2. is red-black tree ?
          add new node
        3. append element into list
          1. list size is >= 7 ?
            transformed the red-black tree when the list size is >= 7
      2. not conflict
        put the element into the hash table

    相关文章

      网友评论

          本文标题:HashMap put(K, V) process

          本文链接:https://www.haomeiwen.com/subject/qyjkjrtx.html