#Removing elements from a list of structures up to a specific one.

1 messages · Page 1 of 1 (latest)

vale smelt
#

Hello, I can't figure out how to remove elements from a list of structures up to a certain one, my code looks like this:
int i = 0;
studentasL paskutinis;
for (auto it = Prad.begin(); it != Prad.end(); ++it)
{
if ((*it).rez_vid >= 5) { paskutinis = (*it); break; }
else {vargsiukai.push_back(*it);}

}
Prad.erase(Prad.begin(), paskutinis);
It goes through a sorted list of structures until it finds the first one with the variable rez_vid <5. Then I need to assign every element from the list up to there to a new list, and every one above that to another, while also maintaining time efficiency

nocturne tendonBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

vale smelt
#

forgot to add how the struct itself looks:
struct studentasL {
string var, pav;
list <int> paz;
int egz;
float rez_vid;
float rez_med;
};

ember thistle
#
int i = 0;
studentasL paskutinis;
for (auto it = Prad.begin(); it != Prad.end(); ++it)
{
    if ((it).rez_vid >= 5) { paskutinis = (it); break; }
    else {vargsiukai.push_back(*it);}

}
Prad.erase(Prad.begin(), paskutinis);
#
struct studentasL {
    string var, pav;
    list <int> paz;
    int egz;
    float rez_vid;
    float rez_med;
};