CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/DataFormats/Provenance/src/BranchChildren.cc

Go to the documentation of this file.
00001 #include "DataFormats/Provenance/interface/BranchChildren.h"
00002 
00003 namespace edm {
00004   void
00005   BranchChildren::append_(map_t const& lookup, BranchID item, BranchIDSet& itemSet) const {
00006     BranchIDSet const& items = const_cast<map_t &>(lookup)[item];
00007     // For each parent(child)
00008     for (BranchIDSet::const_iterator ci = items.begin(), ce = items.end();
00009         ci != ce; ++ci) {
00010       // Insert the BranchID of the parents(children) into the set of ancestors(descendants).
00011       // If the insert succeeds, append recursively.
00012       if (itemSet.insert(*ci).second) {
00013         append_(lookup, *ci, itemSet);
00014       }
00015     }
00016   }
00017 
00018   void
00019   BranchChildren::clear() {
00020     childLookup_.clear();
00021   }
00022 
00023   void
00024   BranchChildren::insertEmpty(BranchID parent) {
00025     childLookup_.insert(std::make_pair(parent, BranchIDSet()));
00026   }
00027 
00028   void
00029   BranchChildren::insertChild(BranchID parent, BranchID child) {
00030     childLookup_[parent].insert(child);
00031   }
00032 
00033   void
00034   BranchChildren::appendToDescendants(BranchID parent, BranchIDSet& descendants) const {
00035     descendants.insert(parent);
00036     append_(childLookup_, parent, descendants);
00037   }
00038 }