java容器(since jdk1.5版) Version 0.2b, 2006/10/26 ================== 各容器介面摘要(功能定義): Collection 收藏: 放個別物件, 可重複放,無位置概念,無排序 Queue 佇列: 放個別物件, 可重複放,頭位置概念,部份排序 List 清單: 放個別物件, 可重複放,任意位置 ,無排序 Set 集合: 放個別物件,不可重複放,無位置概念,無排序 SortedSet 有序集合: 放個別物件,不可重複放,有頭尾概念,有排序 Map 映射: 放成對物件,不可重複放,無位置概念,無排序 SortedMap 有序映射: 放成對物件,不可重複放,有頭尾概念,有排序 各容器類別摘要(實作各介面的實體類別): Collection: Vector,Stack,ArrayList,ArrayBlockingQueue, LinkedList,PriorityQueue,HashSet,TreeSet Queue: ArrayBlockingQueue,LinkedList,PriorityQueue List: Vector,Stack,ArrayList,LinkedList Set: HashSet,TreeSet SortedSet: TreeSet Map: HashMap,TreeMap,HashTable,Properties SortedMap: TreeMap -- Vector 向量,Stack 堆疊,ArrayList 陣列清單,LinkedList 鏈結清單, ArrayBlockingQueue 陣列等候佇列,PriorityQueue 順位佇列, HashSet 雜湊集合,TreeSet 樹狀集合, HashMap 雜湊映射,TreeMap 樹狀映射, HashTable 雜湊表,Properties 屬性表 容器演算法: Collections.binarySearch/min/max/indexOfSublist/lastIndexOfSublist, fill/copy/swap/shuffle/sort/reverse/rotate, list/nCopies/enumeration/reverseOrder, singleton/singletonList/singletonMap, synchronizedCollection/synchronizedSet/synchronizedList, synchronizedMap/synchronizedSortedSet/synchronizedSortedMap, unmodifiableCollection/unmodifiableSet/unmodifiableList, unmodifiableMap/unmodifiableSortedSet/unmodifiableSortedMap, Arrays.asList/binarySearch/equals/fill/sort, 容器一般性功能須求: 新增容器,刪除容器,查詢容器元素個數,列舉容器元素, 新增元素,刪除元素,修改元素,查詢元素,擷取元素 各容器類別提供的方法: Vector >AbstractList >AbstractCollection, 存取有同步,有元素概念,容量無限 *add/addElement/insertElementAt/addAll, *remove/removeElement/removeElementAt, clear/removeAllElements/removeAll/retainAll/removeRange, *get/set/firstElement/lastElement/elementAt/setElementAt, *indexOf/lastIndexOf, subList/toArray/copyInto, isEmpty/contains/containsAll/equals/hasCode, *size/setSize/trimToSize/capacity/ensureCapacity, toString/clone, -- iterator/listIterartor Stack >Vector >AbstractList >AbstractCollection, 存取有同步 *empty/push/peek/pop/search, -- add/addElement/insertElementAt/addAll, remove/removeElement/removeElementAt, clear/removeAllElements/removeAll/retainAll/removeRange, get/set/firstElement/lastElement/elementAt/setElementAt, indexOf/lastIndexOf, subList/toArray/copyInto, isEmpty/equals/contains/containsAll/hasCode, size/setSize/trimToSize/capacity/ensureCapacity, toString/clone, -- iterator/listIterartor ArrayList >AbstractList >AbstractCollection, 存取無同步,容量無限 *add/addAll, *remove/removeRange/clear, *get/set, *indexOf/lastIndexOf, *isEmpty/contains, size/trimToSize/ensureCapacity, clone/toArray, -- iterator/listIterartor/equals/hasCode, -- containsAll/removeAll/retainAll/toString ArrayBlockingQueue >AbstractQueue >AbstractCollection 存取有同步,容量有限制 clear/contains/drainTo/iterator/ offer/peek/poll/put/remove/take remainingCapacity/size/ toArray/toString -- add/addAll/element/remove -- containsAll/isEmpty/removeAll/retainAll PriorityQueue >AbstractQueue >AbstractCollection 存取無同步,容量無限 add/clear/offer/peek/poll/remove comparator/iterator/size -- addAll/element/remove -- contains/containsAll/isEmpty/removeAll/retainAll toArray/toString LinkedList >AbstractSequentialList >AbstractList >AbstractCollection, 存取無同步,有頭尾概念,容量無限 *add/addAll/addFirst/addLast, *remove/removeFirst/removeLast/clear, *get/set/getFirst/getLast, *contains/indexOf/lastIndexOf, size/listIterator/clone/toArray, -- iterator -- equals/hashCode/removeRange/subList containsAll/isEmpty/removeAll/retainAll/toString HashSet >AbstractSet >AbstractCollection, 存取無同步,無順序概念 *add/remove/clear, *contains/isEmpty/size, *iterator/clone, -- equals/hashCode/removeAll -- addAll/containsAll/retainAll/toArray/toString TreeSet >AbstractSet >AbstractCollection, 存取無同步,有順序概念 *add/addAll/remove/clear, *contains/isEmpty/size, *iterator/clone/comparator, *first/last, *headSet/tailSet/subSet, -- equals/hashCode/removeAll -- containsAll/retainAll/toArray/toString HashMap >AbstractMap, 存取無同步,存放成對物件,無順序概念 *get/put/putAll/remove/clear, *isEmpty/containsKey/containsValue, values/keySet/entrySet, size/clone -- equals/hashCode/toString TreeMap >AbstractMap, 存取無同步,存放成對物件,有順序概念 *get/put/putAll/remove/clear, *containsKey/containsValue, *headMap,tailMap,subMap, values/keySet/entrySet, firstKey/lastKey, size/clone/comparator, -- equals/hashCode/isEmpty/toString HashTable >Dictionaries, 存取有同步,存放成對鍵值組 *get/put/putAll/remove/clear, *isEmpty/containsKey/containsValue/contains, keys/elements/values/keySet/entrySet, size/clone/equals/hasCode/rehash/toString -- get/put/remove, elements/keys, size/isEmpty, Properties >HashTable >Dictionaries, 存取有同步,存放屬性鍵值組 *getProperty/setProperty, *load/store/list, *propertyNames, -- *get/put/putAll/remove/clear, *isEmpty/containsKey/containsValue/contains, keys/elements/values/keySet/entrySet, size/clone/equals/hasCode/rehash/toString 各容器介面提供的方法: Collection add/allAll/remove/removeAll/retainAll/clear, isEmpty/contains/containsAll/equals/hasCode/size, iterator/toArray, Queue >Collection 多了頭位置概念 offer/ poll/remove/ peek/element/ -- add/allAll/remove/removeAll/retainAll/clear, isEmpty/contains/containsAll/equals/hasCode/size, iterator/toArray, List >Collection 多了任意位置概念 add/allAll/remove, get/set, indexOf/lastIndexOf, listIterator/subList, -- add/allAll/remove/removeAll/retainAll/clear, isEmpty/contains/containsAll/equals/hasCode/size, iterator/toArray, Set >Collection 多了不重複存放概念 add/allAll/remove/removeAll/retainAll/clear, isEmpty/contains/containsAll/equals/hasCode/size, iterator/toArray, SortedSet >Set >Collection 多了順序概念 first/last, headSet/tailSet/subSet, comparator, -- add/allAll/remove/removeAll/retainAll/clear, isEmpty/contains/containsAll/equals/hasCode/size, iterator/toArray, Map get/put/putAll/remove/clear, isEmpty/containsKey/containsValue, values/keySet/entrySet, size/equals/hasCode, SortedMap >Map firstKey/lastKey, headMap/tailMap/subMap, comparator, -- get/put/putAll/remove/clear, isEmpty/containsKey/containsValue, values/keySet/entrySet, size/equals/hasCode, 迭代列舉介面提供的方法: Enumeration 列舉介面,不能刪除列舉物件,只能往後列舉 hasMoreElements/nextElement, Iterator 迭代介面,可刪除列舉物件,只能往後列舉 hasNext/next/remove, ListIterator 清單迭代介面,可往前後列舉,及增刪改物件 add/set/remove, hasNext/hasPrevious, next/previous, nextIndex,previousIndex, 可比較及比較器介面提供的方法: java.lang.Comparable 可比較介面 compareTo java.util.Comparator 比較器介面 compare/equals
2009年4月8日 星期三
java container (jdk1.5)
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言