我正在构建一个大型消息队列并仅使用 PUSH 和 POP,这样可以更有效(向量或队列)以最大速度维护大数据
struct MQStruct {
wchar_t *serviceName;
int durability;
int msgType;
int msgHeader;
wchar_t *msgId;
wchar_t *payload;
int payloadSize;
int ttl;
int priority;
}MQStructObj;
vector<MQStruct> MQvector;
queue<MQStruct> MSQ;
int SendMessage(wchar_t *serviceName, int durability, int msgType, int msgHeader, wchar_t *msgId, wchar_t *payload, int payloadSize, int ttl, int priority) {
MQStructObj.serviceName=serviceName;
MQStructObj.durability=durability;
MQStructObj.msgType=msgType;
MQStructObj.msgHeader=msgHeader;
MQStructObj.msgId=msgId;
MQStructObj.payload=payload;
MQStructObj.payloadSize=payloadSize;
MQStructObj.ttl=ttl;
MQStructObj.priority=priority;
//Which one is better (Vector or Queue) in term of memory, speed and why
MSQ.push(MQStructObj);
//OR
MQvector.push_back(MQStructObj);
return 0;
}