-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMessageQueue.java
More file actions
36 lines (31 loc) · 915 Bytes
/
MessageQueue.java
File metadata and controls
36 lines (31 loc) · 915 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
package com.lgcns.test;
import java.util.HashMap;
public class MessageQueue {
private HashMap<String, CustomQueue> queueList;
public MessageQueue() {
queueList = new HashMap<String, CustomQueue>();
}
public boolean createQueue(String queueName, int size) {
if( queueList.containsKey(queueName)) {
return false;
}
queueList.put(queueName, new CustomQueue(queueName, size));
return true;
}
public boolean enqueue(String queueName, String value) {
if (queueList.get(queueName).isFull()) {
return false;
}
queueList.get(queueName).add(value);
return true;
}
public Element dequeue(String queueName) {
return queueList.get(queueName).dequeue();
}
public void changeStatus(String queueName, String uid, boolean used) {
queueList.get(queueName).findElement(uid).setUsed(used);
}
public void remove(String queueName,String uid) {
queueList.get(queueName).remove(uid);
}
}