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

Side by Side Diff: base/id_map.h

Issue 2695393002: Revise the comment on base::IDMap::Replace() (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | 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 #ifndef BASE_ID_MAP_H_ 5 #ifndef BASE_ID_MAP_H_
6 #define BASE_ID_MAP_H_ 6 #define BASE_ID_MAP_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <memory> 10 #include <memory>
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 return; 74 return;
75 } 75 }
76 76
77 if (iteration_depth_ == 0) { 77 if (iteration_depth_ == 0) {
78 data_.erase(i); 78 data_.erase(i);
79 } else { 79 } else {
80 removed_ids_.insert(id); 80 removed_ids_.insert(id);
81 } 81 }
82 } 82 }
83 83
84 // Replaces the value for |id| with |new_data| and returns the existing value 84 // Replaces the value for |id| with |new_data| and returns the existing value.
85 // (as a unique_ptr<> if in IDMapOwnPointer mode). Should only be called with 85 // Should only be called with an already added id.
86 // an already added id.
87 V Replace(KeyType id, V new_data) { 86 V Replace(KeyType id, V new_data) {
88 DCHECK(sequence_checker_.CalledOnValidSequence()); 87 DCHECK(sequence_checker_.CalledOnValidSequence());
89 DCHECK(!check_on_null_data_ || new_data); 88 DCHECK(!check_on_null_data_ || new_data);
90 typename HashTable::iterator i = data_.find(id); 89 typename HashTable::iterator i = data_.find(id);
91 DCHECK(i != data_.end()); 90 DCHECK(i != data_.end());
92 91
93 std::swap(i->second, new_data); 92 std::swap(i->second, new_data);
94 return new_data; 93 return new_data;
95 } 94 }
96 95
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 245
247 // See description above setter. 246 // See description above setter.
248 bool check_on_null_data_; 247 bool check_on_null_data_;
249 248
250 base::SequenceChecker sequence_checker_; 249 base::SequenceChecker sequence_checker_;
251 250
252 DISALLOW_COPY_AND_ASSIGN(IDMap); 251 DISALLOW_COPY_AND_ASSIGN(IDMap);
253 }; 252 };
254 253
255 #endif // BASE_ID_MAP_H_ 254 #endif // BASE_ID_MAP_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698