Java?????Stack ??????
???????????? ???????[ 2015/1/12 13:31:20 ] ????????Java Stack
a.removeElementAt()
public synchronized void removeElementAt(int paramInt) {
this.modCount += 1;
if (paramInt >= this.elementCount)
throw new ArrayIndexOutOfBoundsException(paramInt + " >= "
+ this.elementCount);
if (paramInt < 0)
throw new ArrayIndexOutOfBoundsException(paramInt);
int i = this.elementCount - paramInt - 1;
if (i > 0)
System.arraycopy(this.elementData?? paramInt + 1?? this.elementData??
paramInt?? i);
this.elementCount -= 1;
this.elementData[this.elementCount] = null;
}
|
????removeElementAt()??????????????λ?????????????????λ???????????????Stack?????Vector?????????????????????????????????ж???????????????λ??????????????????????λ??????????????-1????????λ??????????????????????????????????????????<br><strong><br><br>b:elementData(int)<br><br></strong>
????E elementData(int paramInt) {
????return this.elementData[paramInt];
????}
????elementData(int)??????λ???????????????????????????????Stack???????????????????? ??
????c:elementAt(int)
????public synchronized E elementAt(int paramInt) {
????if (paramInt >= this.elementCount)
????throw new ArrayIndexOutOfBoundsException(paramInt + " >= "
????+ this.elementCount);
????return elementData(paramInt);
????}
????elementAt(int paramInt)?????ж????????????????????elementData(paramInt)??????????????
????d:peek()
????public synchronized E peek() {
????int i = size();
????if (i == 0)
????throw new EmptyStackException();
????return elementAt(i - 1);
????}
????????????????peek()???????????λ??????????Stack???±?????鱣?????????0??????????????-1??
????<strong>e:pop()<br></strong>
????public synchronized E pop() {
????int i = size();
????Object localObject = peek();
????removeElementAt(i - 1);
????return localObject;
????}
????pop()?????????????????Stack?????????????????peek()??????????????????????????removeElementAt(int)??????????????????????
????f:addElement(E paramE)
????public synchronized void addElement(E paramE) {
????this.modCount += 1;
????ensureCapacityHelper(this.elementCount + 1);
????this.elementData[(this.elementCount++)] = paramE;
????}
????addElement(E)????????????????????????????????????????????????????????modCount??1??ensureCapacityHelper()??????????Stack???????????????????????????grow()???????????????????????????????MAX_ARRAY_SIZE???????????????????????????????i??????????????????????????????1??
????g:search(Object)
????public synchronized int search(Object paramObject) {
????int i = lastIndexOf(paramObject);
????if (i >= 0)
????return (size() - i);
????return -1;
????}
?????÷??????????????????????λ?????????????????-1?????????????????????????????????????????lastLindexOf(Object)??????????????????????????????±???????????????????????????±?????????λ???????????????????-1????????????λ?÷???????????????????????λ??????????λ???1??
????h:empty()
????public boolean empty() {
????return (size() == 0);
????}
???????????????????0????????size()?????????this.elementCount????????????????
????4.??????С??
????????????????????Vector???????????飬???Stack???????????????????????????????????????????????????????????????Vector??????????synchronized ?????????????????????????????????????????????????Ч?????????????
??????
???·???
??????????????????
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