X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7f4f03348bd07609e258eb3b545bdafc2c881847..6a20b94eaec32fb5224c18d21e141bef70da15d8:/src/mc/ObjectInformation.cpp diff --git a/src/mc/ObjectInformation.cpp b/src/mc/ObjectInformation.cpp index 9d66b0ebb4..08a75fa583 100644 --- a/src/mc/ObjectInformation.cpp +++ b/src/mc/ObjectInformation.cpp @@ -108,32 +108,35 @@ void ObjectInformation::remove_global_variable(const char* name) return; // Binary search: - size_type start = 0; - size_type end = this->global_variables.size() - 1; + size_type first = 0; + size_type last = this->global_variables.size() - 1; - while (start <= end) { - size_type cursor = start + (end - start) / 2; + while (first <= last) { + size_type cursor = first + (last - first) / 2; simgrid::mc::Variable& current_var = this->global_variables[cursor]; int cmp = current_var.name.compare(name); if (cmp == 0) { + // Find the whole range: - start = cursor; - while (start != 0 && this->global_variables[start - 1].name == name) - start--; + size_type first = cursor; + while (first != 0 && this->global_variables[first - 1].name == name) + first--; size_type size = this->global_variables.size(); - end = cursor; - while (end != size - 1 && this->global_variables[end + 1].name == name) - end++; + size_type last = cursor; + while (last != size - 1 && this->global_variables[last + 1].name == name) + last++; + // Remove the whole range: this->global_variables.erase( - this->global_variables.begin() + cursor, - this->global_variables.begin() + end + 1); + this->global_variables.begin() + first, + this->global_variables.begin() + last + 1); + return; } else if (cmp < 0) - start = cursor + 1; + first = cursor + 1; else if (cursor != 0) - end = cursor - 1; + last = cursor - 1; else break; }