-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFixedQueue.java
More file actions
35 lines (28 loc) · 773 Bytes
/
Copy pathFixedQueue.java
File metadata and controls
35 lines (28 loc) · 773 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
package qpack;
public class FixedQueue implements ICharQ {
private char q[];
private int putloc, getloc;
public FixedQueue(int size) {
q = new char[size + 1];
putloc = getloc = 0;
}
public void put(char ch) throws QueueFullException {
if(putloc == q.length - 1) {
throw new QueueFullException(q.length - 1);
}
putloc++;
q[putloc] = ch;
}
public char get() throws QueueEmptyException {
if(getloc == putloc) {
throw new QueueEmptyException();
}
getloc++;
return q[getloc];
}
public void reset() {
int newSize = q.length;
q = new char[newSize + 1];
putloc = getloc = 0;
}
}