Java.until.Map,Set,List的资料整理

王朝java/jsp·作者佚名  2008-05-19
窄屏简体版  字體: |||超大  

1.CollecitonFramework(J2SDK1.4 )一般用途Class作方式

2.Collection Framework(J2SDK 1.4)一般用途Class特色与食用范围比较

Collections = Collection是所有List跟Set的始祖,List必须以特定次序来持有对象,Set无法拥有重复元素

ArrayList = 用Array实做的List,答应快速随机存取,相较于LinkedList 不适合拿来进行元素安插和移除动作

LinkedList = 提供最佳循序存取,适合安插和移除元素,随机存取动作比起ArrayList缓慢

HashSet = 是一种collection,但是只存放唯一值,是把搜寻时间看的很重要的set,用hash方式实作的set,故access time complexity = O(1)

TreeSet = 同上,但是存入的元素都会经过排列,所以速度比HashSet 慢一点

LinkedHashSet =

Performance is likely to be just slightly below that of HashSet, due to the added eXPense of maintaining the linked list, with one exception: Iteration over a LinkedHashSet requires time PRoportional to the size of the set, regardless of its capacity. Iteration over a HashSet is likely to be more expensive, requiring time proportional to its capacity.

BitSet = 能够高效率的储存大量 [ 1 / 0 ] (开/关) 资料

HashMap = 用来取代HashTable,储存 (key/value) pairs

TreeMap = 储存 (key/value) pairs,会自动根据Key值排序

LinkedHashMap =

Performance is likely to be just slightly below that of HashMap, due to the added expense of maintaining the linked list, with one exception: Iteration over the collection-views of a LinkedHashMap requires time proportional to the size of the map, regardless of its capacity. Iteration over a HashMap is likely to be more expensive, requiring time proportional to its capacity.

IdentityHashMap =

This has better locality for large tables than does using separate arrays.) For many JRE implementations and Operation mixes, this class will yield better performance than HashMap (which uses chaining rather than linear-probing

WeakHashMap = 这个map中,由于每个Value仅存在一个实体,因而节省了储存空间,一但程序需要某个Value,便在map中搜寻既有的对象,并使用找到的那个对象(而非重新再造一个),由于这是一种节省储存空间的技巧,所以能够方便的让GC自动清理Key和Value,一但Key不在被使用,便会触发清理动作

容器简介

1.容器的分类

1.1.Collection:一组各自独立的元素,即其内的每个位置仅持有一个元素。

1)List:以元素安插的次序来放置元素,不会重新排列。

2)Set:不接爱重复元素,它会使用自己内部的一个排列机制

1.2.Map:一群成对的key-value对象,即所持有的是key-value pairs。

Map中不能有重复的key,它拥有自己的内部排列机制。

2.容器中的元素类型都为Object。从容器取得元素时,必须把它转换成原来的类型。

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航