`
tanglei198577
  • 浏览: 57861 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类

The difference of some collections

    博客分类:
  • java
阅读更多

The content of this chapter is from Think in Java 3th ,bruce ecekl

ArrayList 
由数组实现的 List。允许对元素进行快速随机访问,但是向 List 中间插入与移除元素的速度很慢。ListIterator 只应该用来由后向前遍历 ArrayList,而不是用来插入和移除元素,因为那比 LinkedList 开销要大很多。
LinkedList
对顺序访问进行了优化,向 List 中间插入与删除的开销并不大。随机访问则相对较慢。(使用 ArrayList 代替。)还具有下列方法:addFirst(),addLast(),getFirst(),getLast(),removeFirst(),和 removeLast(),这些方法(没有在任何接口或基类中定义过)使得 LinkedList 可以当作堆栈、队列和双向队列使用。


Set (interface) 存入 Set 的每个元素都必须是唯一的,因为 Set 不保存重复元素,加入 Set 的元素必须定义 equals()方法以确保对象的唯一性。Set 与 Collection 有完全一样的接口。Set 接口不保证维护元素的次序。   

HashSet*:
   为快速查找设计的 Set,存入 HashSet 的对象必须定义hashCode().
TreeSet:
   保持次序的 Set,底层为树结构。使用它可以从 Set中提取有序的序列。
LinkedHashSet:
   具有 HashSet 的查询速度,且内部使用链表维护元素的顺序(插入的次序)。于是在使用迭代器遍历 Set时,结果会按元素插入的次序显示。

HashMap*:
         Map 基于散列表的实现。 (取代了 Hashtable)插入和查询“键值对”的开销是固定的。可以通过构造器设置容量

capacity 和负载因子 loadfactor,以调整容器的性能。

LinkedHashMap:
         类似于 HashMap,但是迭代遍历它时,取得“键值对”的顺序是其插入次序,或者是最近最少使用(LRU)的次序。只比

HashMap 慢一点。而在迭代访问时反而更快,因为它使用链表维护内部次序。

TreeMap:
      基于红黑树数据结构的实现。查看“键”或“键值对”时,它们会被排序(次序由 Comparable或 Comparator 决定,稍后会讨论)。TreeMap的特点在于,你得到的结果是经过排序的。TreeMap 是唯一的带有 subMap()方法的 Map,它可以返回一个子树。

WeakHashMap:
            弱键(weak key)Map,Map 中使用的对象也被允许释放;这是为解决特殊问题设计的。如果没有 map 之外的引用指向某个“键”,则此键”可以被垃圾收集器回收。

0
0
分享到:
评论

相关推荐

    Similarity Search The Metric Space Approach

    After describing the most popular centralized disk-based metric indexes, approximation techniques are presented as a way to significantly speed up search time at the cost of some imprecision in query...

    commons-collections4-4.1

    Commons-Collections seek to build upon the JDK classes by providing new interfaces, implementations and utilities. There are many features, including: Bag interface for collections that have a number...

    Collins W (2004). Data Structures and the Java Collections Framework..pdf

    Collins W (2004). Data Structures and the Java Collections Framework..pdf

    commons-collections.jar

    commons-collections-20040616.jar, commons-collections-3.2-osgi.jar, commons-collections-3.2-sources.jar, commons-collections-3.2.1.jar, commons-collections-3.2.2-javadoc.jar, commons-collections-3.2.2...

    collections-of-the-basis-of-compute-system-2nd.bin

    collections-of-the-basis-of-compute-system-2nd.bin

    Data Structures and the Java Collections Framework(3rd) 无水印pdf

    Data Structures and the Java Collections Framework(3rd) 英文无水印pdf 第3版 pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源...

    Beginning Swift: Master the fundamentals of programming in Swift 4 pdf

    Then, master the usage of key language elements, such as strings and collections. Finally, grasp how Swift supports modern application development using advanced features, such as built-in Unicode ...

    Power Collections

    Power Collections is free for all to use within the bounds of the standard Eclipse End user license agreement. If you feel you would like to contribute, please feel free to contact one of the project ...

    APress Java Collections

    Java数据结构相关知识,是一本非常不错的书籍。 This book is about Java's support for dealing with groups of data.... We'll also look at some of the common alternate frameworks available.

    commons-collections4-4.4-API文档-中文版.zip

    赠送jar包:commons-collections4-4.4.jar; 赠送原API文档:commons-collections4-4.4-javadoc.jar; 赠送源代码:commons-collections4-4.4-sources.jar; 赠送Maven依赖信息文件:commons-collections4-4.4.pom;...

    数据结构和Java集合框架《Data Structures and the Java Collections Framework》

    译自《Data Structures and the Java Collections Framework》,之前在同平台的其他用户下载的这本书,竟然索要积分50。遂感不平,特再次共享这个资源。

    commons-collections-3.2.2-API文档-中文版.zip

    赠送jar包:commons-collections-3.2.2.jar; 赠送原API文档:commons-collections-3.2.2-javadoc.jar; 赠送源代码:commons-collections-3.2.2-sources.jar; 赠送Maven依赖信息文件:commons-collections-3.2.2....

    The Book of F#

    F# brings the power of functional-first programming to the .NET Framework, a platform for developing software in the Microsoft Windows ecosystem. If you’re a traditional .NET developer used to C# and...

    Java Collections Apress

    Java Collections Apress This book describes how to use this Collections Framework. We'll also look at some of the common alternate frameworks available.

    commons-collections4-4.1-API文档-中文版.zip

    赠送jar包:commons-collections4-4.1.jar; 赠送原API文档:commons-collections4-4.1-javadoc.jar; 赠送源代码:commons-collections4-4.1-sources.jar; 赠送Maven依赖信息文件:commons-collections4-4.1.pom;...

    Collections

    Collections 中部分方法详解如GridView中Collections.swap

    collections-generic-4.01_and_looks-2.1.4

    该文件里包含两个.jar包: collections-generic-4.01.jar和looks-2.1.4.jar, 引入collections-generic-4.01.jar: 右击工程--》Build path ——》Add External JAR-->选中collections-generic-4.01.jar --》OK 在源...

    commons-collections4-4.4-API文档-中英对照版.zip

    赠送jar包:commons-collections4-4.4.jar; 赠送原API文档:commons-collections4-4.4-javadoc.jar; 赠送源代码:commons-collections4-4.4-sources.jar; 赠送Maven依赖信息文件:commons-collections4-4.4.pom;...

    Java 7 Concurrency Cookbook

    Chapter 6, Concurrent Collections will teach the readers to how to use some concurrent data structures provided by the Java language. These data structures must be used in concurrent programs to avoid...

Global site tag (gtag.js) - Google Analytics