main(){
	struct pilha p;
    inicializa(&p);

    printf("Comeco Vazio : %d\n", vaziaBegin(&p));
    printf("Final Vazio : %d\n", vaziaEnd(&p));
    printf("Cheia : %d\n\n", cheia(&p));
    pushBegin(&p, 1);
    pushBegin(&p, 1);
    pushBegin(&p, 1);
    pushBegin(&p, 1);
    pushEnd(&p, 1);
    pushEnd(&p, 1);
    pushEnd(&p, 1);
    pushEnd(&p, 1);
    pushEnd(&p, 1);
    printf("\nComeco Vazio : %d\n", vaziaBegin(&p));
    printf("Final Vazio : %d\n", vaziaEnd(&p));
    printf("Cheia : %d\n\n", cheia(&p));
    printf("pop Begin : %d\n", popBegin(&p));
    printf("pop Begin : %d\n", popBegin(&p));
    printf("pop Begin : %d\n", popBegin(&p));
    printf("pop Begin : %d\n", popBegin(&p));
    printf("pop End : %d\n", popEnd(&p));
    printf("pop End : %d\n", popEnd(&p));
    printf("pop End : %d\n", popEnd(&p));
    printf("pop End : %d\n", popEnd(&p));
    printf("pop End : %d\n\n", popEnd(&p));
    printf("Comeco Vazio : %d\n", vaziaBegin(&p));
    printf("Final Vazio : %d\n", vaziaEnd(&p));
    printf("Cheia : %d\n\n", cheia(&p));
	getchar();
}
Beispiel #2
0
//------------------------------------------------------------------------------
int main(){

    std::clog << "Program started\n";

    // create the work queue to comunicate threads
    auto jobq = std::make_shared<MyQueue>( 10 );

    // create the working threads
    std::thread tprod1 {producer, jobq, 1.0 };
    std::thread tprod2 {producer, jobq, 100.0 };

    std::thread tcons {consumer, jobq};

    // wait for producers end generate work
    tprod1.join();
    tprod2.join();

    // push the end of work
    jobq->pushEnd();

    // wait for consumer end
    tcons.join();

    std::clog << "Program ended\n";

    return EXIT_SUCCESS;
}
List<KeyType>::List(const List<KeyType>& list){
    
    first_ = 0;
    Node<KeyType>* tmp = list.first_;
    while (tmp != 0){
        pushEnd(tmp->key_);
        tmp = tmp->next_;
    }
}