美文网首页
ArrayMap VS HashMap

ArrayMap VS HashMap

作者: KaelQ | 来源:发表于2016-09-12 09:23 被阅读86次

    1.ArrayMap和HashMap概况

    • HashMap:采用数组和链表模式存储数据。
      ArrayMap:采用一个hashcode数组和一个数组对象存储数据。数组偶数为key,奇数为value。

    2.两者不同

    • 存储方式不同
      HashMap采用数组和链表模式存储数据。
      ArrayMap采用一个hashcode数组和一个数组对象存储数据。
    • 扩容方式不同
      HashMap是新new一个对象。
      ArrayMap是copy,比HashMap更加节省内存。
    • 查找方式不同
      HashMap是利用迭代器。
      ArrayMap是利用二分查找法。
    • 收缩不同
      HashMap 去掉元素后无法收缩。
      ArrayMap 提供了数组收缩,在去掉元素后能够收缩数组。

    相关文章

      网友评论

          本文标题:ArrayMap VS HashMap

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