<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                **Java源碼之Stack** 轉載請注明出處:[http://blog.csdn.net/itismelzp/article/details/50371987](http://blog.csdn.net/itismelzp/article/details/50371987) Stack的源碼較短,在這里直接貼出: Stack繼承自Vetor實現的,所以基礎的策略也來自Vector ~~~ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package java.util; /** * {@code Stack} is a Last-In/First-Out(LIFO) data structure which represents a * stack of objects. It enables users to pop to and push from the stack, * including null objects. There is no limit to the size of the stack. */ public class Stack<E> extends Vector<E> { private static final long serialVersionUID = 1224463164541339165L; /** * Constructs a stack with the default size of {@code Vector}. */ public Stack() { } /** * 調用父類方法isEmpty判斷 */ public boolean empty() { return isEmpty(); } /** * 返回棧頂元素(元素不刪除) */ @SuppressWarnings("unchecked") public synchronized E peek() { try { return (E) elementData[elementCount - 1]; // elementData見Vector } catch (IndexOutOfBoundsException e) { throw new EmptyStackException(); } } /** * 刪除棧頂元素,并返回頂棧元素 */ @SuppressWarnings("unchecked") public synchronized E pop() { if (elementCount == 0) { throw new EmptyStackException(); } final int index = --elementCount; final E obj = (E) elementData[index]; elementData[index] = null; modCount++; return obj; } /** * 元素入棧 */ public E push(E object) { addElement(object); // 依然是父類方法addElement return object; } /** * 返回元素在棧中的索引(棧頂元素索引為0,往下遞增) */ public synchronized int search(Object o) { final Object[] dumpArray = elementData; final int size = elementCount; if (o != null) { for (int i = size - 1; i >= 0; i--) { if (o.equals(dumpArray[i])) { return size - i; } } } else { for (int i = size - 1; i >= 0; i--) { if (dumpArray[i] == null) { return size - i; } } } return -1; } } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看