当前位置: 首页>>代码示例>>C++>>正文


C++ MyQueue类代码示例

本文整理汇总了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
}
开发者ID:io-eft,项目名称:di-systems-programming-third-project,代码行数:30,代码来源:mythreads.cpp

示例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;
			}					
		}			
	}
}
开发者ID:shadow3x3x3,项目名称:C-DataStructure,代码行数:30,代码来源:complete_BST_linklist.cpp

示例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);

}
开发者ID:DimpleOrg,项目名称:InterviewDS,代码行数:33,代码来源:test.cpp

示例4: main

int main() {
    MyQueue<int> q;
    q.add(5);
    q.add(6);
    int t = q.remove();
    cout << t << endl;
    return 0;
}
开发者ID:rajesh-kr,项目名称:cloaked-octo-avenger,代码行数:8,代码来源:pb3.5.cpp

示例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;
}
开发者ID:LarryJ,项目名称:CTCI,代码行数:10,代码来源:3_5.cpp

示例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) {
开发者ID:ulisesmx,项目名称:exercises,代码行数:10,代码来源:stack_queue.cpp

示例7: main

int main()
{
    MyQueue<int> mq;
    mq.add(1);
    mq.add(2);
    mq.remove();
    mq.printAll();
    debug("Hello world!", "");
    return 0;
}
开发者ID:zs634134578,项目名称:DailyTouch,代码行数:10,代码来源:040twoStackToQueue.cpp

示例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;
}
开发者ID:wyxmails,项目名称:MyCode,代码行数:11,代码来源:03.05.cpp

示例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
}
开发者ID:io-eft,项目名称:di-systems-programming-third-project,代码行数:13,代码来源:mythreads.cpp

示例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() << " ";
	}
}
开发者ID:evancloutier,项目名称:programmingquestions,代码行数:13,代码来源:Q3.5.cpp

示例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;
}
开发者ID:starcroce,项目名称:ctci_4_and_5,代码行数:14,代码来源:ctci_3_5.cpp

示例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;
}
开发者ID:gautamgitspace,项目名称:CTCIv5.0,代码行数:15,代码来源:main.cpp

示例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;
}
开发者ID:cdht,项目名称:Algorithm,代码行数:15,代码来源:3.5.cpp

示例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;
    }
}
开发者ID:WolfForMoon,项目名称:Local-C-Code,代码行数:15,代码来源:main.cpp

示例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;
}
开发者ID:gerhard2202,项目名称:Data-Structures-Classwork,代码行数:17,代码来源:listsandbox.cpp


注:本文中的MyQueue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。