Java??Vector???Stack?????
???????????? ???????[ 2014/3/12 10:45:37 ] ????????Vector?? Stack?? Java
????1.Vector??
????API?????????
????Vector?????????????????????顣???????????????????????????????????з??????????????Vector ???С?????????????????С??????????? Vector ????????????????????
????java.util.vector??????????(vector)???????????????????????Java???????????????????????????????????????????????????????????????c??c++????ν??“???????”??????????????????????????Java????????????????????????vector???????????????????????????????????????????????????????????????????????????????????á?
???????????????????????????????????????????????????????????????????????????????????????????????в??????????????????????????????С????????????????в??????????????????????????????????????
????Vector?????????ArrayList??????????????????????????????????????Synchorized?????????????е?Ч?????ArrayList?????
????Vector??ArrayList?????
??????1??????????????
????Vector:
????protected Object[] elementData;
????ArrayList??
????private transient Object[] elementData;
????(2)?????
????Vector?????????????????????????????????дVector????????????д????????????????????????????????????????????????ArrayList????
??????Vector???е?isEmpty???????:
????public synchronized boolean isEmpty() {
????return elementCount == 0;
????}
????public boolean isEmpty() { //ArrayList??
????return size == 0;
????}
??????3????治?????????С
????ArrayList????治???????????1.5??
private void grow(int minCapacity) {
// overflow-conscious code
int oldCapacity = elementData.length;
int newCapacity = oldCapacity + (oldCapacity >> 1);
if (newCapacity - minCapacity < 0)
newCapacity = minCapacity;
if (newCapacity - MAX_ARRAY_SIZE > 0)
newCapacity = hugeCapacity(minCapacity);
// minCapacity is usually close to size?? so this is a win:
elementData = Arrays.copyOf(elementData?? newCapacity);
}
//oldCapacity>>1??????λ?????????????2??1?η???????????0.5????CPU??????λ????????Ч?????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11