本文整理汇总了C++中MyQueue类的典型用法代码示例。如果您正苦于以下问题:C++ MyQueue类的具体用法?C++ MyQueue怎么用?C++ MyQueue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MyQueue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: terminator
void* terminator(void* args)
{
std::cout << "I'll be back!" << std::endl; //couldn't help it
MyThreadArgs* mta = (MyThreadArgs*)args; //get the arguments
int sock = mta->getMainSock(); //store them locally
MyQueue* mq = mta->getQueue();
pthread_t* workers = mta->getWorkerThreads();
int workersAmount = mta->getWorkersAmount();
pthread_t mainThread = mta->getMainThread();
mq->waitForActiveThreads(); //wait for all active firstLineThreads to finish
if(close(sock) == -1) //close the main socket
perror("close");
for(int i = 0; i < workersAmount; i++)
{ //join all worker threads
mq->signalWorkersForExit();
pthread_join(workers[i], NULL);
}
pthread_kill(mainThread, SIGRTMIN+1); //signal the main thread to exit
pthread_join(mainThread, NULL); //join it
delete mq; //delete all allocated memory
delete[] workers;
delete mta;
pthread_detach(pthread_self()); //detach yourself
exit(0); //and exit
}
示例2: Levelorder
//Levelorder
void BS_Tree::Levelorder()
{
TreeNode *temp;
MyQueue S;
temp = root;
if(temp == NULL){
printf("Tree is empty.\n");
}
else{
S.AddQ(temp);
while(true){
temp = S.DelQ();
if(temp != NULL){
printf("%d ",temp->key);
if(temp->left != NULL){
S.AddQ(temp->left);
}
if(temp->right != NULL){
S.AddQ(temp->right);
}
}
else{
break;
}
}
}
}
示例3: TEST
TEST(D_QueueViaStacksTest, Test1)
{
std::string output;
testing::internal::CaptureStdout();
MyQueue<int> mq;
try
{
mq.enqueue(1);
mq.enqueue(2);
mq.enqueue(3);
mq.enqueue(4);
mq.enqueue(5);
std::cout << "\n Front element in queue is " << mq.front();
mq.dequeue();
mq.dequeue();
mq.dequeue();
mq.dequeue();
mq.dequeue();
//std::cout << "\n Front element in queue is " << mq.front();
mq.enqueue(6);
std::cout << "\n Front element in queue is " << mq.front();
}
catch (std::exception e)
{
std::cout << e.what();
}
output = testing::internal::GetCapturedStdout();
EXPECT_EQ(1, 1);
}
示例4: main
int main() {
MyQueue<int> q;
q.add(5);
q.add(6);
int t = q.remove();
cout << t << endl;
return 0;
}
示例5: main
int main()
{
MyQueue q;
cout << q.pop() << endl;
q.push(1);
q.push(10);
cout << q.pop() << endl;
cout << q.pop() << endl;
return 0;
}
示例6: main
int main() {
MyQueue q;
int t, type, data;
cin >> t;
for (int i = 0; i < t; i++) {
cin >> type;
if (type == 1) {
cin >> data;
q.push(data);
} else if (type == 2) {
示例7: main
int main()
{
MyQueue<int> mq;
mq.add(1);
mq.add(2);
mq.remove();
mq.printAll();
debug("Hello world!", "");
return 0;
}
示例8: main
int main(int argc,char*argv[]){
MyQueue mq;
for(int i=1;i<=5;++i)
mq.push(i);
for(int i=1;i<=6;++i){
cout << "front: " << mq.front() << endl;
cout << "back: " << mq.back() << endl;
mq.pop();
}
return 0;
}
示例9: workerThread
void* workerThread(void* args)
{
MyQueue* mq = (MyQueue*)args; //get the arguments
while(true) //keep running
{
MyJob* mj = mq->popTop(); //get a job
if(mj == NULL) //if it's empty
break; //stop running
mj->sendFileToClient(); //else, send it to client
delete mj; //delete the job
}
pthread_exit(NULL); //exit
}
示例10: main
int main() {
MyQueue testQueue;
for (int i = 0; i < 10; i++) {
testQueue.enqueue(i);
std::cout << i << " ";
}
std::cout << std::endl;
for (int i = 0; i < 10; i++) {
std::cout << testQueue.dequeue() << " ";
}
}
示例11: main
int main(int argc, char const *argv[])
{
MyQueue<int> q;
for(int i = 0; i < 10; i++)
{
q.push(i);
}
cout<<q.front()<<" "<<q.rear()<<endl;
q.pop();
cout<<q.front()<<" "<<q.rear()<<endl;
q.push(11);
cout<<q.front()<<" "<<q.rear()<<endl;
return 0;
}
示例12: main
int main()
{
MyQueue myqueue = *new MyQueue();
myqueue.enqueue(10);
myqueue.enqueue(20);
myqueue.enqueue(30);
myqueue.enqueue(40);
myqueue.enqueue(50);
cout<<"NOW SERVING: "<<myqueue.dequeue()<<endl;
cout<<"NEXT IN LINE: "<<myqueue.outbox.top()<<endl;
return 0;
}
示例13: main
int main()
{
MyQueue q;
q.Push(1);
q.Push(2);
q.Push(3);
q.Push(3);
while(q.Empty() == false)
{
int v = q.PopFront();
cout << v << " ";
}
cout << endl;
}
示例14: Output
void Output(BinTree<char> &B)
{
int num;
MyQueue<char> Q;
B.InOrderInMirror(B.root,Show,Q);
int i=0;
char arr[DEFAULTSIZE];
B.PreOrder(B.root,arr,i);
while (!Q.IsEmpty())
{
num=NumCal(arr,Q.getFront());
for (i=1;i<num;i++) cout<<" ";
cout<<Q.DeQueue()<<endl;
}
}
示例15: main
int main(){
MyStack<int> a;
MyQueue<int> c;
a.push(4);
a.push(5);
cout << a.top() << endl;
a.pop();
cout << a.top() << endl;
c.enqueue(4);
c.enqueue(5);
cout << c.front() << endl;
c.dequeue();
cout << c.front() << endl;
}