Linked List ADT / Return and-or increment an objects member


Algorithmically / Pesudo
What I would like to accomplish is.

-> Add and object
-> If list is not empty then.
-> CheckSum the Name of New Object (return an int)
-> Do A linear Search of linked list using the member.checksum as the key
-> If object is found increment member.qty
-> if object is found add new item to list

Here is the section of code in question.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
void Inventory::AddItem(const Item& addData){

        nodePtr n = new node;
        n->next = nullptr;
    
        n->aItem = addData;


    if (!isEmpty()) {
        cout << "CheckSumming... trace" << endl;
        // CheckSum Name Of New Object
        CheckSum CheckName;
        int CheckSum;
        CheckSum = CheckName.GetCheckSum(addData.getName());
    

    }

        if (head != nullptr)
        {
            curr = head;
            while (curr->next != nullptr)
            {
                curr = curr->next;
            }
            curr->next = n;
        }
        else
        {
            head = n;
        }
} // end AddItem 



What I would like help with is the

-> Do A linear Search of linked list using the member.checksum as the key

I am thinking I my the function should return and object?

Topic archived. No new replies allowed.