此作业旨在探索链表,因此您将实现一个单链表来保存从 CSV 文件加载的投标集合
This assignment is designed to explore linked lists so you will implement a singly linked-list to hold a collection of bids loaded from a CSV file
我需要帮助它总是给我相同的号码而不是不同的号码。
Bid LinkedList::Search(string bidId) {
// FIXME (6): Implement search logic
// special case if matching node is the head
// make head point to the next node in the list
//decrease size count
//return
// start at the head of the list
// keep searching until end reached with while loop (next != nullptr
// if the current node matches, return it
// else current node is equal to next node
//return bid
Node* temp = head;
Node* holder = new Node;
holder->bid.bidId = "";
while (temp != nullptr) {
cout << temp->bid.bidId << endl;
if (temp->bid.bidId == bidId) {
return temp->bid;
}
temp = temp->next;
return holder->bid;
}
}
只需删除带有 holder
的所有内容。最后在没有找到任何东西时抛出异常。或者 return std::optional<Bid>
.
我需要帮助它总是给我相同的号码而不是不同的号码。
Bid LinkedList::Search(string bidId) {
// FIXME (6): Implement search logic
// special case if matching node is the head
// make head point to the next node in the list
//decrease size count
//return
// start at the head of the list
// keep searching until end reached with while loop (next != nullptr
// if the current node matches, return it
// else current node is equal to next node
//return bid
Node* temp = head;
Node* holder = new Node;
holder->bid.bidId = "";
while (temp != nullptr) {
cout << temp->bid.bidId << endl;
if (temp->bid.bidId == bidId) {
return temp->bid;
}
temp = temp->next;
return holder->bid;
}
}
只需删除带有 holder
的所有内容。最后在没有找到任何东西时抛出异常。或者 return std::optional<Bid>
.