Hello people

I am in need of help with part of my program... How can I edit a element in my percent list?

I want the user to be able to change the percentage (that is aready there) so that it can ... update, and then be sorted it...

void System::editList(list<string>& team, list<double>& percent, list<int>& pv, list<int>& wins, list<int>& losses)
{

    system("cls");

    percent.sort(bubblesort);

    for(it = percent.begin(); it != percent.end(); it++){

            cout << ' ' << *it;
            cout << endl;
    }

    system("pause");
    system("cls");
}

Thanks

Are the various lists supposed to be syncronized? That is, are the same length, and corresponding elements of each list refer to the same thing or event? If so, you might want to consider using a class that incorporates all that information and then make a list or map of that.

You are passing lots of information you never seem to use to this function. You might want to remove the unused arguments from the function definition.

The std::list is defined such that the contents of the list are not meant to be altered once stored. To edit an item, find it in the list, get the entire object in the list, edit it, put it in the list near the original, then remove the original. Using an iterator on the list will make these operations much faster.

An insertion sort will tend to be a lot faster than bubble sort in a list. Establish the part of the list is sorted and part is not; initially only the first element is considered sorted. Using an iterator, keep track of the end of the sorted part, then figure out where each subsequent element goes in the sorted list and move it there. This can be much faster if most of the list is already sorted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.