forked from java-test88/test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLinkedStack
52 lines (46 loc) · 920 Bytes
/
LinkedStack
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package first;
import java.util.LinkedList;
public class LinkedList {
public class LinkedStack implements Stack {
private LinkedList<Object> list = new LinkedList<Object>();
@Override
public Object pop() {
// TODO Auto-generated method stub
if (isEmpty()) {
return null;
}else {
return list.removeFirst();
}
}
@Override
public Object peek() {
// TODO Auto-generated method stub
if(isEmpty()) {
return null;
}else {
return list.getFirst();
}
}
@Override
public void push(Object e) {
// TODO Auto-generated method stub
list.addFirst(e);
}
@Override
public void clear() {
// TODO Auto-generated method stub
list.clear();
}
@Override
public int size() {
// TODO Auto-generated method stub
return list.size();
}
@Override
public boolean isEmpty() {
// TODO Auto-generated method stub
return list.isEmpty();
}
}
}
}