學習Java數據結構-集合

http://zh.visualgo.net/
Note: 數據集合存儲結構,默認no synchronized,允許NULL,允許duplicate
Tree結構支持內部元素根據指定的規則排序

Collection
├List
│├LinkedList
│├ArrayList
│└Vector
│ └Stack
└Set
├HashSet
├TreeSet
Map
├Hashtable
├TreeMap
├HashMap
└WeakHashMap

Collection

List

  • LinkedList
  • 實現了List<E>, Deque<E>, Queue<E>
  • List 【Every* element in the {@code List} has an index;allow duplicate* elements, as compared to Sets, where elements have to be unique】
  • Deque 【double ended queue】【FIFO (First-In-First-Out) 】【Deques can also be used as LIFO (Last-In-First-Out) stacks】

注:push-pollLast 滿足LIFO
add-poll滿足FIFO

  • you should probably use {@link ArrayList} if you don't need the queue-like behavior.
  • ArrayList

ArrayList is an implementation of {@link List}, backed by an array.

  • Vector

Vector is an implementation of {@link List}, backed by an array and synchronized.

  • Stack
  • {@code Stack} is a **Last-In/First-Out(LIFO) *data structure which represents a stack of objects.
  • including null objects. There is no limit to the size of the stack.

Set

(A {@code Set} is a data structure which does not allow duplicate elements.)

  • TreeSet
  • 實現了SortedSet接口,支持元素排序
  • HashSet

Map

A {@code Map} is a data structure consisting of a set of keys and values in which each key is mapped to a single value.

  • HashTable
  • Hashtable is a synchronized implementation of {@link Map}. All optional operations are supported.
  • **Neither keys nor values can be null. *(Use {@code HashMap} or {@code LinkedHashMap} if you need null keys or values.)
  • TreeMap

A map whose entries are sorted by their keys.

  • HashMap

Note: the implementation of {@code HashMap} is not synchronized.

  • WeakHashMap

WeakHashMap is an implementation of Map with keys which are WeakReferences.

  • LinkedHashMap

doubly-linked list

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容