Ignore:
Timestamp:
Jul 11, 2018, 4:26:22 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
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)
Message:

Persistent-array environment compiles

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/PersistentMap.h

    r184557e r5c14030  
    139139                        case BASE: {
    140140                                for (const auto& entry : as<Base>()) {
    141                                         gc << entry.first << entry.second;
     141                                        gc.maybe_trace( entry.first, entry.second );
    142142                                }
    143143                                return;
     
    145145                        case REM: {
    146146                                const Rem& self = as<Rem>();
    147                                 gc << self.base << self.key;
     147                                gc << self.base;
     148                                gc.maybe_trace( self.key );
    148149                                return;
    149150                        }
    150151                        case INS: case UPD: {
    151152                                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 );
    153155                                return;
    154156                        }
     
    424426        }
    425427
     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
    426435        /// Applies the function `f` to all elements of the map, returning a pointer to the updated map.
    427436        /// `f` should take two parameters, `const Key&` and `Val&`, returning option<Val> filled with
     
    429438        /// NOTE: when porting to C++17, this should work fine with std::optional
    430439        template<typename F>
    431         Self* apply_to_all(F&& f) {
     440        Self* mutate_each(F&& f) {
    432441                // reset to root and exit early if no change
    433442                if ( rerooted().empty() ) return this;
     
    454463                return next_edit;
    455464        }
    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         }
    463465};
    464466
Note: See TracChangeset for help on using the changeset viewer.