Index: base/values.cc |
=================================================================== |
--- base/values.cc (revision 15654) |
+++ base/values.cc (working copy) |
@@ -497,11 +497,8 @@ |
} |
void ListValue::Clear() { |
- ValueVector::iterator list_iterator = list_.begin(); |
- while (list_iterator != list_.end()) { |
- delete *list_iterator; |
- ++list_iterator; |
- } |
+ for (ValueVector::iterator i(list_.begin()); i != list_.end(); ++i) |
+ delete *i; |
list_.clear(); |
} |
@@ -609,13 +606,19 @@ |
else |
delete list_[index]; |
- ValueVector::iterator entry = list_.begin(); |
- entry += index; |
- |
- list_.erase(entry); |
+ list_.erase(list_.begin() + index); |
return true; |
} |
+void ListValue::Remove(Value* in_value) { |
+ for (ValueVector::iterator i(list_.begin()); i != list_.end(); ++i) { |
+ if ((*i)->Equals(in_value)) { |
+ list_.erase(i); |
+ break; |
+ } |
+ } |
+} |
+ |
void ListValue::Append(Value* in_value) { |
DCHECK(in_value); |
list_.push_back(in_value); |
@@ -624,11 +627,8 @@ |
Value* ListValue::DeepCopy() const { |
ListValue* result = new ListValue; |
- ValueVector::const_iterator current_entry = list_.begin(); |
- while (current_entry != list_.end()) { |
- result->Append((*current_entry)->DeepCopy()); |
- ++current_entry; |
- } |
+ for (ValueVector::const_iterator i(list_.begin()); i != list_.end(); ++i) |
+ result->Append((*i)->DeepCopy()); |
return result; |
} |