I have a vector within a vector defined as:
std::vector<std::vector<myObj>> some_list(list_size);
some of the entries in some_list have elements and some don't those that have 3 elements have size 3 those with 4 have size 4 etc. for example:
some_list[0] {size=3}
some_list[1] {size=4}
but at some point there is an empty entry with 0 elements such as:
some_list[14] {size=0}
after which point every entry that follows has size 0 as well.
I am trying to resize my vector so it excludes such entries and is left with only the entries that have elements. But for some reason I can't make it work. Here's what I have:
int snum = 0;
for (std::vector<std::vector<myObj>>::iterator a_it = a_list.begin();
a_it != a_list.end(); a_it++) {
while (a_it->size() != 0) {
snum++;
}
}
a_list.resize(snum);