용기 학습10: Vector & ArrayList & LinkedList
2169 단어 LinkedList
둘.Vector & ArrayList
//ArrayList
public void ensureCapacity(int minCapacity) {
modCount++;
int oldCapacity = elementData.length;
if (minCapacity > oldCapacity) {
Object oldData[] = elementData;
// (oldCapacity * 3)/2 + 1
int newCapacity = (oldCapacity * 3)/2 + 1;
if (newCapacity < minCapacity)
newCapacity = minCapacity;
// minCapacity is usually close to size, so this is a win:
elementData = Arrays.copyOf(elementData, newCapacity);
}
}
//Vector
private void ensureCapacityHelper(int minCapacity) {
int oldCapacity = elementData.length;
if (minCapacity > oldCapacity) {
Object[] oldData = elementData;
// capacityIncrement,Vector
// oldCapacity + capacityIncrement oldCapacity * 2
int newCapacity = (capacityIncrement > 0) ?
(oldCapacity + capacityIncrement) : (oldCapacity * 2);
if (newCapacity < minCapacity) {
newCapacity = minCapacity;
}
elementData = Arrays.copyOf(elementData, newCapacity);
}
}
셋.ArrayList & LinkedList
넷.PS
기술 함량이 매우 없는 문장, 벽돌을 찍는 것을 환영하고, 평론을 환영하며, 나로 하여금 Vector & Array List & Linked List가 또 나의 눈앞을 밝게 할 수 있는 것이 있는지 발견하게 한다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Java 컬렉션 프레임워크LinkedList 상세 정보 및 인스턴스Java 컬렉션 프레임워크LinkedList 상세 정보 LinkedList 정의 LinkedList 개요 LinkedList는 양방향 체인 테이블로 이루어지며 중복을 허용합니다.(아래 Node 구현) 헤더 및 끝 바...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.