Skip to content

Commit

Permalink
replace set with vector for collections
Browse files Browse the repository at this point in the history
  • Loading branch information
gaede authored and tmadlener committed Dec 11, 2022
1 parent dbd14f3 commit b8e04ef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
17 changes: 9 additions & 8 deletions src/cpp/include/UTIL/CheckCollections.h
Expand Up @@ -18,7 +18,7 @@ namespace UTIL {
*/
class CheckCollections {

typedef std::set<std::pair<std::string,std::string>> Set ;
typedef std::vector<std::pair<std::string,std::string>> Vector ;

public:

Expand All @@ -44,22 +44,23 @@ namespace UTIL {

/** Returns the collections that are not present in all events checked with checkFiles() with their names and types.
*/
Set getMissingCollections() const ;
Vector getMissingCollections() const ;

/** Returns the collections that are present in all events checked with checkFiles() with their names and types.
*/
Set getConsistentCollections() const ;
Vector getConsistentCollections() const ;

/** Add a collection with (name,type) that should be added to events in patchEvent().
*/
void addPatchCollection(const std::string name, std::string type){
_patchCols.emplace( name, type ) ;
_patchCols.push_back( {name, type} ) ;
}

/** Add a all collections as Set(name,type), e.g. retrieved from getMissingCollections() that should be added to events in patchEvent().
/** Add a all collections as Vector(name,type), e.g. retrieved from getMissingCollections() that should be added to events in patchEvent().
*/
void addPatchCollections(Set cols){
_patchCols.merge( cols ) ;
void addPatchCollections(Vector cols){
for(const auto& p : cols)
_patchCols.push_back( p ) ;
}

/** Add and empty collection to the event for any collection that is in patchCollections and not in the Event
Expand All @@ -69,7 +70,7 @@ namespace UTIL {
private:
unsigned _nEvents =0 ;
std::unordered_map< std::string, std::pair< std::string, unsigned > > _map{} ;
Set _patchCols {} ;
Vector _patchCols {} ;

}; // class

Expand Down
12 changes: 6 additions & 6 deletions src/cpp/src/UTIL/CheckCollections.cc
Expand Up @@ -49,21 +49,21 @@ namespace UTIL{
}


CheckCollections::Set CheckCollections::getMissingCollections() const {
Set s ;
CheckCollections::Vector CheckCollections::getMissingCollections() const {
Vector s ;
for(const auto& e : _map ){
if( e.second.second != _nEvents )
s.emplace( std::make_pair(e.first, e.second.first ) ) ;
s.push_back( {e.first, e.second.first } ) ;
}
return s ;
}


CheckCollections::Set CheckCollections::getConsistentCollections() const {
Set s ;
CheckCollections::Vector CheckCollections::getConsistentCollections() const {
Vector s ;
for(auto e : _map ){
if( e.second.second == _nEvents )
s.emplace( std::make_pair(e.first, e.second.first ) ) ;
s.push_back( {e.first, e.second.first }) ;
}
return s ;
}
Expand Down

0 comments on commit b8e04ef

Please sign in to comment.