ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/Stack.java
(Generate patch)

Comparing jsr166/src/main/java/util/Stack.java (file contents):
Revision 1.2 by jsr166, Sat Oct 1 21:43:43 2005 UTC vs.
Revision 1.3 by jsr166, Sat Oct 1 22:07:26 2005 UTC

# Line 8 | Line 8
8   package java.util;
9  
10   /**
11 < * The <code>Stack</code> class represents a last-in-first-out
12 < * (LIFO) stack of objects. It extends class <tt>Vector</tt> with five
13 < * operations that allow a vector to be treated as a stack. The usual
11 > * The <code>Stack</code> class represents a last-in-first-out
12 > * (LIFO) stack of objects. It extends class <tt>Vector</tt> with five
13 > * operations that allow a vector to be treated as a stack. The usual
14   * <tt>push</tt> and <tt>pop</tt> operations are provided, as well as a
15 < * method to <tt>peek</tt> at the top item on the stack, a method to test
16 < * for whether the stack is <tt>empty</tt>, and a method to <tt>search</tt>
15 > * method to <tt>peek</tt> at the top item on the stack, a method to test
16 > * for whether the stack is <tt>empty</tt>, and a method to <tt>search</tt>
17   * the stack for an item and discover how far it is from the top.
18   * <p>
19 < * When a stack is first created, it contains no items.
19 > * When a stack is first created, it contains no items.
20   *
21 < * <p>A more complete and consistent set of LIFO stack operations are
22 < * available in {@link Deque} interface and its implementations, which
21 > * <p>A more complete and consistent set of LIFO stack operations is
22 > * provided by the {@link Deque} interface and its implementations, which
23   * should be used in preference to this class.  For example:
24 < * <pre>
25 < *   Deque&lt;Integer&gt; stack = new ArrayDeque&lt;Integer&gt();
26 < * </pre>
24 > * <pre>   {@code
25 > *   Deque<Integer> stack = new ArrayDeque<Integer>();}</pre>
26   *
27   * @author  Jonathan Payne
28   * @version %I%, %G%
# Line 38 | Line 37 | class Stack<E> extends Vector<E> {
37      }
38  
39      /**
40 <     * Pushes an item onto the top of this stack. This has exactly
40 >     * Pushes an item onto the top of this stack. This has exactly
41       * the same effect as:
42       * <blockquote><pre>
43       * addElement(item)</pre></blockquote>
# Line 54 | Line 53 | class Stack<E> extends Vector<E> {
53      }
54  
55      /**
56 <     * Removes the object at the top of this stack and returns that
57 <     * object as the value of this function.
56 >     * Removes the object at the top of this stack and returns that
57 >     * object as the value of this function.
58       *
59 <     * @return     The object at the top of this stack (the last item
59 >     * @return     The object at the top of this stack (the last item
60       *             of the <tt>Vector</tt> object).
61       * @exception  EmptyStackException  if this stack is empty.
62       */
# Line 72 | Line 71 | class Stack<E> extends Vector<E> {
71      }
72  
73      /**
74 <     * Looks at the object at the top of this stack without removing it
75 <     * from the stack.
74 >     * Looks at the object at the top of this stack without removing it
75 >     * from the stack.
76       *
77 <     * @return     the object at the top of this stack (the last item
78 <     *             of the <tt>Vector</tt> object).
77 >     * @return     the object at the top of this stack (the last item
78 >     *             of the <tt>Vector</tt> object).
79       * @exception  EmptyStackException  if this stack is empty.
80       */
81      public synchronized E peek() {
# Line 90 | Line 89 | class Stack<E> extends Vector<E> {
89      /**
90       * Tests if this stack is empty.
91       *
92 <     * @return  <code>true</code> if and only if this stack contains
92 >     * @return  <code>true</code> if and only if this stack contains
93       *          no items; <code>false</code> otherwise.
94       */
95      public boolean empty() {
# Line 98 | Line 97 | class Stack<E> extends Vector<E> {
97      }
98  
99      /**
100 <     * Returns the 1-based position where an object is on this stack.
101 <     * If the object <tt>o</tt> occurs as an item in this stack, this
102 <     * method returns the distance from the top of the stack of the
103 <     * occurrence nearest the top of the stack; the topmost item on the
104 <     * stack is considered to be at distance <tt>1</tt>. The <tt>equals</tt>
105 <     * method is used to compare <tt>o</tt> to the
100 >     * Returns the 1-based position where an object is on this stack.
101 >     * If the object <tt>o</tt> occurs as an item in this stack, this
102 >     * method returns the distance from the top of the stack of the
103 >     * occurrence nearest the top of the stack; the topmost item on the
104 >     * stack is considered to be at distance <tt>1</tt>. The <tt>equals</tt>
105 >     * method is used to compare <tt>o</tt> to the
106       * items in this stack.
107       *
108       * @param   o   the desired object.
109 <     * @return  the 1-based position from the top of the stack where
109 >     * @return  the 1-based position from the top of the stack where
110       *          the object is located; the return value <code>-1</code>
111       *          indicates that the object is not on the stack.
112       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines