Category : stdlist

I defined this list: using SpecialEventList = list<SPECIAL_EVENT_S*>; The items are added to this list like this: m_listNewSpecialEvents.push_back(psEvent); The original list of SPECIAL_EVENT_S pointers is owned and managed by another list help in the app class. My concern is that when this dialog closes that m_listNewSpecialEvents will automatically delete the pointers and I don’ want ..

Read more

I have a std::list<struct Data> data. I need to sort data by head in according to the rule rule. For this I am using std::list::sort(Compare comp). The implementation below works, however it is inefficient. Finding the element in the rule list requires traversing the list, calculating the distance requires traversing the list again. How else ..

Read more

I’m writing a function that handles an order input file (csv) using a while loops to iterate though it. 762212,1,2020-03-15,10951-3,64612-2,57544-1,80145-1,27515-2,16736-1,79758-2,29286-2,51822-3,39096-1,32641-3,63725-3,64007-2,23022-1,16974-3,26860-2,75536-2,26461-1 1,373975319551257,12-2023 258572,2,2020-03-15,96497-1,70616-1,80237-2,22248-2,56107-1,59695-1,37948-3,21316-3,63498-1,18329-1,56833-1,66295-1,47680-3,30346-1 1,201741963232463,02-2022 857003,3,2020-03-15,16655-1,88019-3,75069-3,96017-2,46883-2,15138-1,77316-1,70063-3,54452-3,86429-2,15134-2,60176-1,12946-3 2,cfeeham3s 747893,4,2020-03-17,48520-1,93268-2,63636-1,23750-2,99771-3,83203-1,21316-3,89921-2,15134-3,82831-1,30346-2,54044-3,28561-1,14792-2,23523-3,56826-2 1,3571379825697064,04-2025 Every two lines represents an input. I have the following function that handles this input: list<Order> orders; void read_orders(string file_name) { fstream read_file; read_file.open(file_name, ios::in); if (read_file.is_open()) { ..

Read more

When I try to read items from std::list I read one more item than available in the list: int i = 0; m_entities.clear(); for (list<DxfEntity*>::const_iterator it = other.m_entities.cbegin(); it != other.m_entities.cend(); ++it) { qDebug("%d: src_size=%d dst_size=%d", i++, (int)other.m_entities.size(), (int)m_entities.size()); m_entities.push_back((*it)->clone()); } when I use for (const DxfEntity* entity: other.m_entities) m_entities.push_back(entity->clone()); I have same problem. If ..

Read more

Hello im trying to print a list of ints and i keep getting that erro. I have a structure that have a list on it. struct faceFiguration{ int faceID; list<int> setofVertices; }; And i have a list of that sructure list<faceFiguration> pattern; and heres where i get confuse, i trie to print the lists here: ..

Read more