-
Notifications
You must be signed in to change notification settings - Fork 0
/
IntDeque.java
executable file
·134 lines (103 loc) · 1.83 KB
/
IntDeque.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
public class IntDeque {
public static void main(String[] args) {
//sam testing
IntDeque sam = new IntDeque(100);
sam.putLast(4);
System.out.println(sam.peekLast());
//kate's testing area:
IntDeque kate = new IntDeque(100);
kate.putFirst(2);
System.out.println(kate.getFirst()); //hoping for 2
}
int[] q;
int head, tail;
boolean isEmpty() { return head==0 || tail == 0;}
public IntDeque(int defaultsize) {
q = new int[defaultsize];
head=0;
tail=0;
}
/*
put the first item
*/
public void putFirst(int item) {
}
/*
put the last item
*/
public void putLast(int item) {
q[tail++] = item;
}
/*
return the first item
*/
public int peekFirst() {
return 0;
}
/*
return the last item
*/
public int peekLast() {
return q[tail-1];
}
/*
get the first item
*/
public int getFirst() {
if(!isEmpty()) {
int x = q[head - 1];
return x;
}
return 0;
}
/*
get the last item
*/
public int getLast() {
return 0;
}
/*
move num items from first to last
*/
public void circ(int num) {
}
/*
return a Stack from this deque
*/
public IntStack toStack() {
return null;
}
/*
multiply every two items in the queue together,
such that the array is half the size
*/
public void multQueue() {
}
/*
return a Deque which includes only every odd item in this queue
*/
public IntDeque oddQueue() {
return null;
}
/*
print the Deque to the screen
*/
public void print() {
}
/*
add an item to the middle
*/
public void middle(int i) {
}
/*
put an item on both sides
*/
public void putBoth(int i) {
}
/*
get an item from both sides
*/
public int[] getBoth() {
return null;
}
}