1.LinkList
//鏈表節(jié)點(diǎn)模型
private static class Node<E> {
E item;
Node<E> next;
Node<E> prev;
Node(Node<E> prev, E element, Node<E> next) {
this.item = element;
this.next = next;
this.prev = prev;
}
}
2.ArrayList
//初始化大小為10豺鼻;
int DEFAULT_CAPACITY = 10;
//存儲(chǔ)結(jié)構(gòu)為數(shù)組
private transient Object[] elementData;
//擴(kuò)容方式,擴(kuò)大一倍谅年,復(fù)制數(shù)組
private void grow(int minCapacity) {
int oldCapacity = elementData.length;
int newCapacity = oldCapacity + (oldCapacity >> 1);
elementData = Arrays.copyOf(elementData, newCapacity);
}
3.HashSet
//底層為hashMap傍衡,默認(rèn)為16肥缔;
public HashSet(Collection<? extends E> c) {
map = new HashMap<>(Math.max((int) (c.size()/.75f) + 1, 16));
addAll(c);
}
//hashSet對(duì)象為key禀梳,value為固定的object對(duì)象的hashMap菩浙,具體看hashMap方法
public boolean add(E e) {
return map.put(e, PRESENT)==null;
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者