java.util.Collection
- List
- Set
- SortedSet
- NavigableSet
- Queue
- Deque

/*** Returns the number of elements in this collection. If this collection* contains more than <tt>Integer.MAX_VALUE</tt> elements, returns* <tt>Integer.MAX_VALUE</tt>.** @return the number of elements in this collection*/int size(); size最大大小Integer.MAX_VALUE
HashSet有序?
HashSet底层是HashMap 值是new Object();
static final int hash(Object key) {int h;return (key == null) ? 0 : (h = key.hashCode()) ^ (h >>> 16);}public int hashCode() {int h = hash;if (h == 0 && value.length > 0) {char val[] = value;for (int i = 0; i < value.length; i++) {h = 31 * h + val[i];}hash = h;}return h;}


LinkedList list = new LinkedList();Queue queue = new LinkedList();Deque deque = new LinkedList();
java.util.concurrent.BlockingQueue
java.util.concurrent.BlockingDeque
java.util.concurrent.TransferQueue
https://www.jrebel.com/blog/java-collections-cheat-sheet
java.util.HashMap
- java.util.SortedMap
- java.util.NavigableMap
- java.util.concurrent.ConcurrentHashMap
一致性Hashpublic HashSet() {map = new HashMap<>();}
https://github.com/Jaskey/ConsistentHash
https://github.com/clohfink/RendezvousHash/
遗留实现
- Vector
数组实现,线程安全
- Stack
- Hashtable
key value都不允许null
- Enumeration
StringTokenizer
- BitSet

抽象实现
AbstractCollection
AbstractList
面试题
DeepCloneDemo
Collection是单纬度数据集合
Map是二维数据集合
Java集合遍历实现
- java.util.Collections
- java.util.Arrays
不变集合
Collections.SingletonList();
singletonMap
singletonList
不变数组
空集合接口
- Collections.emptyEnumeration()
- Collections.emptyIterator()
Collections.emptyListIterator()
转换接口
List Collections.list(Enumeration
) Arrays.asList(T …) - Set Collections.newSetFromMap
- Queue Collections.asLifoQueue(Deque
) - HashCode Arrays.hashCode()
-
列举集合
BitSet.valueOf
- EnumSet.valueOf
- Stream.of
-
包装实现
Collections.synchronized*
- Collections.unmodifiable*
- Collections.checked*
集合特殊实现
- WeakHashMap
- ThreadLocal.ThreadLocalMap
- IdentityHashMap
- PriorityQueue
- EnumSet

