Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: base/values.h

Issue 7892052: Adds Find method to the ListValue class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplified the code a bit. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/values.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // This file specifies a recursive data storage class called Value intended for 5 // This file specifies a recursive data storage class called Value intended for
6 // storing setting and other persistable data. It includes the ability to 6 // storing setting and other persistable data. It includes the ability to
7 // specify (recursive) lists and dictionaries, so it's fairly expressive. 7 // specify (recursive) lists and dictionaries, so it's fairly expressive.
8 // However, the API is optimized for the common case, namely storing a 8 // However, the API is optimized for the common case, namely storing a
9 // hierarchical tree of simple values. Given a DictionaryValue root, you can 9 // hierarchical tree of simple values. Given a DictionaryValue root, you can
10 // easily do things like: 10 // easily do things like:
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 411
412 // Appends a Value if it's not already present. Takes ownership of the 412 // Appends a Value if it's not already present. Takes ownership of the
413 // |in_value|. Returns true if successful, or false if the value was already 413 // |in_value|. Returns true if successful, or false if the value was already
414 // present. If the value was already present the |in_value| is deleted. 414 // present. If the value was already present the |in_value| is deleted.
415 bool AppendIfNotPresent(Value* in_value); 415 bool AppendIfNotPresent(Value* in_value);
416 416
417 // Insert a Value at index. 417 // Insert a Value at index.
418 // Returns true if successful, or false if the index was out of range. 418 // Returns true if successful, or false if the index was out of range.
419 bool Insert(size_t index, Value* in_value); 419 bool Insert(size_t index, Value* in_value);
420 420
421 // Searches for the first instance of |value| in the list using the Equals
422 // method of the Value type.
423 // Returns a const_iterator to the found item or to end() if none exists.
424 const_iterator Find(const Value& value) const;
425
421 // Swaps contents with the |other| list. 426 // Swaps contents with the |other| list.
422 void Swap(ListValue* other) { 427 void Swap(ListValue* other) {
423 list_.swap(other->list_); 428 list_.swap(other->list_);
424 } 429 }
425 430
426 // Iteration. 431 // Iteration.
427 iterator begin() { return list_.begin(); } 432 iterator begin() { return list_.begin(); }
428 iterator end() { return list_.end(); } 433 iterator end() { return list_.end(); }
429 434
430 const_iterator begin() const { return list_.begin(); } 435 const_iterator begin() const { return list_.begin(); }
(...skipping 30 matching lines...) Expand all
461 466
462 } // namespace base 467 } // namespace base
463 468
464 // http://crbug.com/88666 469 // http://crbug.com/88666
465 using base::DictionaryValue; 470 using base::DictionaryValue;
466 using base::ListValue; 471 using base::ListValue;
467 using base::StringValue; 472 using base::StringValue;
468 using base::Value; 473 using base::Value;
469 474
470 #endif // BASE_VALUES_H_ 475 #endif // BASE_VALUES_H_
OLDNEW
« no previous file with comments | « no previous file | base/values.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698