bool Trace::erase_earlier_than(const unsigned p_time) { if (p_time == 0 || empty() || GetFront().point.GetTime() >= p_time) // there will be nothing to remove return false; do { TraceDelta &td = GetFront(); td.Remove(); auto i = delta_list.find(td); assert(i != delta_list.end()); delta_list.erase(i); --cached_size; } while (!empty() && GetFront().point.GetTime() < p_time); // need to set deltas for first point, only one of these // will occur (have to search for this point) if (!empty()) erase_start(GetFront()); return true; }
bool Trace::erase_earlier_than(const unsigned p_time) { if (!p_time) // there will be nothing to remove return false; bool modified = false; while (!chronological_list.IsEmpty() && ((TraceDelta *)chronological_list.GetNext())->point.time < p_time) { TraceDelta &td = *(TraceDelta *)chronological_list.GetNext(); td.Remove(); delta_list.erase(td.delta_list_iterator); --cached_size; modified = true; } // need to set deltas for first point, only one of these // will occur (have to search for this point) if (modified && !delta_list.empty()) erase_start(*(TraceDelta *)chronological_list.GetNext()); return modified; }