65 |
|
* @see java.util.Vector#addElement |
66 |
|
*/ |
67 |
|
public E push(E item) { |
68 |
< |
addElement(item); |
68 |
> |
addElement(item); |
69 |
|
|
70 |
< |
return item; |
70 |
> |
return item; |
71 |
|
} |
72 |
|
|
73 |
|
/** |
79 |
|
* @exception EmptyStackException if this stack is empty. |
80 |
|
*/ |
81 |
|
public synchronized E pop() { |
82 |
< |
E obj; |
83 |
< |
int len = size(); |
82 |
> |
E obj; |
83 |
> |
int len = size(); |
84 |
|
|
85 |
< |
obj = peek(); |
86 |
< |
removeElementAt(len - 1); |
85 |
> |
obj = peek(); |
86 |
> |
removeElementAt(len - 1); |
87 |
|
|
88 |
< |
return obj; |
88 |
> |
return obj; |
89 |
|
} |
90 |
|
|
91 |
|
/** |
97 |
|
* @exception EmptyStackException if this stack is empty. |
98 |
|
*/ |
99 |
|
public synchronized E peek() { |
100 |
< |
int len = size(); |
100 |
> |
int len = size(); |
101 |
|
|
102 |
< |
if (len == 0) |
103 |
< |
throw new EmptyStackException(); |
104 |
< |
return elementAt(len - 1); |
102 |
> |
if (len == 0) |
103 |
> |
throw new EmptyStackException(); |
104 |
> |
return elementAt(len - 1); |
105 |
|
} |
106 |
|
|
107 |
|
/** |
111 |
|
* no items; <code>false</code> otherwise. |
112 |
|
*/ |
113 |
|
public boolean empty() { |
114 |
< |
return size() == 0; |
114 |
> |
return size() == 0; |
115 |
|
} |
116 |
|
|
117 |
|
/** |
129 |
|
* indicates that the object is not on the stack. |
130 |
|
*/ |
131 |
|
public synchronized int search(Object o) { |
132 |
< |
int i = lastIndexOf(o); |
132 |
> |
int i = lastIndexOf(o); |
133 |
|
|
134 |
< |
if (i >= 0) { |
135 |
< |
return size() - i; |
136 |
< |
} |
137 |
< |
return -1; |
134 |
> |
if (i >= 0) { |
135 |
> |
return size() - i; |
136 |
> |
} |
137 |
> |
return -1; |
138 |
|
} |
139 |
|
|
140 |
|
/** use serialVersionUID from JDK 1.0.2 for interoperability */ |