学习Java数据结构-集合

2016-04-23  本文已影响179人  Aberstin

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

  • 实现了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 is an implementation of {@link List}, backed by an array.

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

  • {@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.)

  • 实现了SortedSet接口,支持元素排序

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 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.)

A map whose entries are sorted by their keys.

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

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

doubly-linked list

上一篇 下一篇

猜你喜欢

热点阅读