java/lang/Stack
David Young
kaffe@rufus.w3.org
Sat, 22 Aug 1998 19:27:02 -0400
Shouldn't thse Stack methods (and others) be atomic?
On Sat, Aug 22, 1998 at 02:53:00PM -0700, Archie Cobbs wrote:
> public Object peek() throws EmptyStackException {
> try {
> return elementAt(size() - 1);
> } catch (ArrayIndexOutOfBoundsException _) {
> throw new EmptyStackException();
> }
> }
>
> public Object pop() throws EmptyStackException {
> Object peeked = peek();
>
> removeElementAt(size() - 1);
> return peeked;
> }
--
dyoung@pobox.com
``Ya know, a dyoung, as in `The African dyoung stays in its cool
burrow during the daytime, coming out only at night to forage for
food.'''