Changeset 5c14030 for src/Common/PersistentMap.h
- Timestamp:
- Jul 11, 2018, 4:26:22 PM (6 years ago)
- Branches:
- new-env
- Children:
- d318a18
- Parents:
- 184557e
- git-author:
- Aaron Moss <a3moss@…> (07/11/18 16:10:36)
- git-committer:
- Aaron Moss <a3moss@…> (07/11/18 16:26:22)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PersistentMap.h
r184557e r5c14030 139 139 case BASE: { 140 140 for (const auto& entry : as<Base>()) { 141 gc << entry.first << entry.second;141 gc.maybe_trace( entry.first, entry.second ); 142 142 } 143 143 return; … … 145 145 case REM: { 146 146 const Rem& self = as<Rem>(); 147 gc << self.base << self.key; 147 gc << self.base; 148 gc.maybe_trace( self.key ); 148 149 return; 149 150 } 150 151 case INS: case UPD: { 151 152 const Ins& self = as<Ins>(); 152 gc << self.base << self.key << self.val; 153 gc << self.base; 154 gc.maybe_trace( self.key, self.val ); 153 155 return; 154 156 } … … 424 426 } 425 427 428 /// Applies the function `f` to all elements of the map. 429 /// `f` should take two parameters, `const Key&` and `const Val&`. 430 template<typename F> 431 void for_each(F&& f) const { 432 for ( const auto& entry : rerooted() ) { f( entry.first, entry.second ); } 433 } 434 426 435 /// Applies the function `f` to all elements of the map, returning a pointer to the updated map. 427 436 /// `f` should take two parameters, `const Key&` and `Val&`, returning option<Val> filled with … … 429 438 /// NOTE: when porting to C++17, this should work fine with std::optional 430 439 template<typename F> 431 Self* apply_to_all(F&& f) {440 Self* mutate_each(F&& f) { 432 441 // reset to root and exit early if no change 433 442 if ( rerooted().empty() ) return this; … … 454 463 return next_edit; 455 464 } 456 457 /// Applies the function `f` to all elements of the map.458 /// `f` should take two parameters, `const Key&` and `const Val&`.459 template<typename F>460 void apply_to_all(F&& f) const {461 for ( const auto& entry : rerooted() ) { f( entry.first, entry.second ); }462 }463 465 }; 464 466
Note: See TracChangeset
for help on using the changeset viewer.