-
Notifications
You must be signed in to change notification settings - Fork 0
/
CStack.java
52 lines (40 loc) · 870 Bytes
/
CStack.java
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 stacks;
import components.FineCursorArray;
public class CStack<T extends Comparable<T>> {
FineCursorArray list = new FineCursorArray(); // the size is read from the number of sections
int top;
public CStack() {
list.initializer();
}
public int creatList() {
return list.createList();
}
public boolean isEmpty(int l) {
if (list.isEmpty(l) == true) {
return true;
}
return false;
}
public void clear(int l) {
if (!isEmpty(l)) {
}
}
public void push(T data, int l) {
list.insertFirst(data, l);
}
public T pop(int l) {
if (!isEmpty(l)) {
T toDel = (T) list.firstElement(l);
list.deleteFirst(l);
return toDel;
}
return null;
}
public T peek(int l) {
if (!isEmpty(l)) {
T first = (T) list.firstElement(l);
return first;
}
return null;
}
}