1 3 package org.jgroups.util; 4 5 6 import java.io.IOException ; 7 import java.io.ObjectInput ; 8 import java.io.ObjectOutput ; 9 10 11 12 15 public class Stack extends List { 16 17 18 public Stack() {} 19 20 21 public void push(Object obj) { 22 addAtHead(obj); 23 } 24 25 public Object pop() { 26 return removeFromHead(); 27 } 28 29 public Object peek() { 30 return peekAtHead(); 31 } 32 33 34 public Object bottom() { 35 return super.peek(); 36 } 37 38 39 public boolean empty() { 40 return size <= 0; 41 } 42 43 44 public List copy() { 45 Stack retval=new Stack(); 46 47 synchronized(mutex) { 48 for(Element el=head; el != null; el=el.next) 49 retval.add(el.obj); 50 } 51 return retval; 52 } 53 54 55 56 public void writeExternal(ObjectOutput out) throws IOException { 57 super.writeExternal(out); 58 } 59 60 61 62 public void readExternal(ObjectInput in) throws IOException , ClassNotFoundException { 63 super.readExternal(in); 64 } 65 66 67 68 69 70 74 75 79 80 84 87 88 96 97 98 100 } 101 | Popular Tags |