学习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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容