-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStackX.java
More file actions
47 lines (34 loc) · 865 Bytes
/
Copy pathStackX.java
File metadata and controls
47 lines (34 loc) · 865 Bytes
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
class StackX {
private Deque deque;
private int nItems;
private int maxSize;
private long[] stackXArray;
private int top;
public StackX(int s) // constructor
{
deque = new Deque(s);
maxSize = s;
stackXArray = new long[maxSize];
top = -1;
}
public void push(long j) // put item on top of stack
{
stackXArray[++top] =j;
// TODO implement
}
public long pop() // take item from top of stack
{
return stackXArray[top--];
}
public boolean isEmpty() // true if stack is empty
{
{
return (top == -1);
}
// TODO implement
}
public boolean isFull() // true if stack is full
{
return (top == maxSize-1);
}
}