Java常用单线程数据结构比较
2010-07-15 14:01
351 查看
Lists
Maps
Sets
Type | Random access | Insertions and removals | Multi-threading | Additional Info |
Vector<?> | Very good,born for it | Not very good | thread-safe | Direct-subclass : stack |
ArrayList<?> | Same as vector | Same as vector | No support,need explicit synchronizing | |
LinkedList<?> | Costly | Very good,should be the option within the catalog | Not thread-safe | Actually is a doubly-linked list can be used as stack, queue, or double-ended queue (deque). |
Type | Storage-based | Time complexity(key locating) | Multi-threading | Additional info |
Hasktable<K,V> | Hash | O(1) | Internally synchronized | |
HashMap<K,V> | Hash | 0(1) | Not synchronized | Conceptually the same as hashtable except for the thread-safety |
LinkedHashMap<K,V> | Hash | O(1) | Not synchronized | Use the same technique as the hashmap and hashtable classes to store the data. However,it also maintains a running linkedlist that contains all of the keys in the map in a sorted order |
IdentityHashMap<K,V> | Hash | O(1) | Not synchronized | Objects are compared based on identity(only if the same instance ),not equality |
Weakhashmap<K,V> | Hash | O(1) | Not synchronized | Keys are sorted in weak references |
TreeMap<K,V> | Balanced binary tree | O(log2(n)) | Not synchronized | Regarding to sorted key order , this is better at storing large sets of data,since log2(n) grows very slowly as n increases,this size trade-off is often worth the cost. |
Type | Storage-based | Multi-threading | Additional info |
---|---|---|---|
Hashset<E> | Hash | Not synchronized | Merely insert a dummy value for each key in the map and hide the face that it is using a map from the user |
LinkedHashSet<E> | Hash | Not synchronized | Maintain a linkedlist of the objects in the set,which can significantly decrease the amount of available memory |
TreeSet<E> | Binary balanced tree | Not synchronized | Inherit the same benefits and limitations as the TreeMap class |
相关文章推荐
- java常用数据结构的比较
- Java常用的通信协议效率比较(转)
- JAVA之旅(十六)——String类,String常用方法,获取,判断,转换,替换,切割,子串,大小写转换,去除空格,比较
- java线程安全之Concurrent.util常用类(十六)
- 常用 Java 静态代码分析工具的分析与比较
- java常用的几种线程池比较
- Java——线程间通信 常用方法
- 常用回顾3------Java的线程和Java Applet
- 常用 Java 静态代码分析工具的分析与比较
- Java基础知识和常用数据结构整理与分析--Framwork篇
- java处理Json大字符串和常用数据结构的相互转换
- atitit.常用编程语言的性能比较 c c++ java
- 比较Java中几个常用集合添加元素的效率
- 常用数据结构及其性能比较
- Java常用数据结构
- Java常用的数据结构
- JAVA提高篇(33)--Java线程常用的操作方法
- 常用 Java 静态代码分析工具的分析与比较
- 常用的java日期比较和日期计算方法小结
- java常用的比较方法