OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/values.h" | 5 #include "base/values.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 | 10 |
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 } | 825 } |
826 } | 826 } |
827 return -1; | 827 return -1; |
828 } | 828 } |
829 | 829 |
830 void ListValue::Append(Value* in_value) { | 830 void ListValue::Append(Value* in_value) { |
831 DCHECK(in_value); | 831 DCHECK(in_value); |
832 list_.push_back(in_value); | 832 list_.push_back(in_value); |
833 } | 833 } |
834 | 834 |
| 835 bool ListValue::AppendIfNotPresent(Value* in_value) { |
| 836 DCHECK(in_value); |
| 837 for (ValueVector::iterator i(list_.begin()); i != list_.end(); ++i) { |
| 838 if ((*i)->Equals(in_value)) |
| 839 return false; |
| 840 } |
| 841 list_.push_back(in_value); |
| 842 return true; |
| 843 } |
| 844 |
835 bool ListValue::Insert(size_t index, Value* in_value) { | 845 bool ListValue::Insert(size_t index, Value* in_value) { |
836 DCHECK(in_value); | 846 DCHECK(in_value); |
837 if (index > list_.size()) | 847 if (index > list_.size()) |
838 return false; | 848 return false; |
839 | 849 |
840 list_.insert(list_.begin() + index, in_value); | 850 list_.insert(list_.begin() + index, in_value); |
841 return true; | 851 return true; |
842 } | 852 } |
843 | 853 |
844 Value* ListValue::DeepCopy() const { | 854 Value* ListValue::DeepCopy() const { |
(...skipping 16 matching lines...) Expand all Loading... |
861 lhs_it != end() && rhs_it != other_list->end(); | 871 lhs_it != end() && rhs_it != other_list->end(); |
862 ++lhs_it, ++rhs_it) { | 872 ++lhs_it, ++rhs_it) { |
863 if (!(*lhs_it)->Equals(*rhs_it)) | 873 if (!(*lhs_it)->Equals(*rhs_it)) |
864 return false; | 874 return false; |
865 } | 875 } |
866 if (lhs_it != end() || rhs_it != other_list->end()) | 876 if (lhs_it != end() || rhs_it != other_list->end()) |
867 return false; | 877 return false; |
868 | 878 |
869 return true; | 879 return true; |
870 } | 880 } |
OLD | NEW |