将列表作为参数传递给函数后,访问链表中的节点,尝试设置多线程列表

时间:2014-10-12 04:01:26

标签: c++ multithreading linked-list

我正在尝试设置多线程链表。我想我已经正确设置了初始列表。正如我在帖子的标题中所说,我无法弄清楚如何访问列表中的节点以添加第二个线程。这是我到目前为止的代码。

void List::setListByName(Winery& winePlace){
    Node * node = new Node;
    Node * curr = headName->nextName;
    Node * prior = headName;
    node->vineyard = winePlace;
    node->nextName = NULL;
    char newWine[CHAR_SIZE] = "Hi";
    char currWine[CHAR_SIZE] = "Hi";
    winePlace.getWineryName(newWine);
    while(curr != tailName){
        curr->vineyard.getWineryName(currWine);
        if(strcmp(currWine, newWine) < 0){
            prior = curr;
            curr = curr->nextName;
        }
        else{
            break;
        }
    }
    prior->nextName = node;
    node->nextName = curr;    
}

void List::qualityScoreSort(List& list){
    Node* curr = headScore->nextRating;
    Node* previous = headScore;
    while(curr != tailScore){
        previous->nextRating = list.Node;//?????
        list.Node.//????
    }
}

0 个答案:

没有答案